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

Florian Weimer
Thu Mar 24 09:28:00 GMT 2011

* Edmon Begoli:

> How does compiler translate a following line of code into something
> that operating system will recognize as an instruction that will map
> to an OS thread:
> ret_value = pthread_create( &thread1, NULL, print_message_function,
>   (void*) message1);

The pthread API only needs very limited compiler support (certain
optimizations are invalid in multithreaded programs).  Portable C code
does not care whether it runs on the main thread or additional threads
created by pthread_create.

The actual thread creation happens in the kernel and in an assembler
helper which set up the initial stack frame for the new thread.  And
there are some bookkeeping structures which need to be updated,
e.g. to allow iterating over all threads in the process.

Florian Weimer                <>
BFK edv-consulting GmbH
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99

More information about the Libc-help mailing list