This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Greetings,

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;
    pthread_mutex_unlock(&count_mutex);
  }

following (excerpt) assembler is generated:

.p2align 4,,15
.globl increment_count
.type   increment_count, @function
increment_count:
.LFB1:
       .cfi_startproc
       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    #
       .cfi_endproc
.LFE1:

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,
Edmon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]