pthread_create

Norman Feske norman.feske at ...1...
Tue Jul 13 12:08:33 CEST 2010


Hi Stephane,

welcome to the list! :-)

> The call does not exist, and I wonder which solution is the best.
> Do I need to wrap all thread creation through genode thread service
> call ?

indeed, there is no implementation of the pthread API yet. So you will
need to implement the needed 'pthread_*' functions. Most applications
use only a small subset of the pthread API, which should be
straight-forward to implement based on Genode's 'Thread', 'Lock',
'Semaphore' (see 'base/include/base'), and 'Timed_semaphore' (see
'os/include/os'). As long as your application does not rely on advanced
pthread features such as real-time scheduling or cancellation handling,
the effort will be fairly reasonable.

As a starting point, I recommend looking at our DDE Kit implementation.
DDE Kit is a library providing a C-based API including functions for
multi-threading and synchonization:

  http://genode.org/documentation/api/dde_kit_index

You may either decide to implement 'pthread_create' and the like as
wrappers around 'dde_kit_thread_*' functions, or take the DDE kit
implementation as blue print for implementing the 'pthread_*' functions
directly ontop of the Genode API. You can find the implementation at
'os/src/lib/dde_kit'.

Please note that the current version of libc is not completely
thread-safe. In particular, 'errno' is just a plain global variable. If
you run into problems with 'errno' reporting strange errors in a
multi-threaded application, we should revisit the current 'errno'
implementation ('libc/src/lib/libc/errno.cc').

Best regards
Norman




More information about the users mailing list