Help for graduate research - how are NLTP routines implemented at the OS level

Edmon Begoli
Sat Mar 19 21:46:00 GMT 2011


For the purpose of graduate class on compliers I am researching
how are concurrent routines compiled into assembler code.

I need help understanding what system calls are used to implement
mutexes and context switches.

Specifically, I looked into this code and how it was compiled into
intermediate assembler and I would like to know

When compiling this code:

#include <pthread.h>
pthread_mutex_t count_mutex;
long long count;
void increment_count()
  { pthread_mutex_lock(&count_mutex);
    count = count + 1;

following (excerpt) assembler is generated:

.p2align 4,,15
.globl increment_count
.type   increment_count, @function
       subq    $8, %rsp        #,
       .cfi_def_cfa_offset 16
       movl    $count_mutex, %edi      #,
       call    pthread_mutex_lock      #
       addq    $1, count(%rip) #, count
       movl    $count_mutex, %edi      #,
       addq    $8, %rsp        #,
       .cfi_def_cfa_offset 8
       jmp     pthread_mutex_unlock    #

I am interested in knowing specifically how is pthread_mutex_lock and
unlock implemented and what OS system calls are used for context
switching (longjmp/setjmp?).

Any help on this or helpful reference is greatly appreciated.

Thank you in advance,

More information about the Libc-help mailing list