Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Realistically, what pthreads functionality is generally used?

Tags:

posix

pthreads

I'm working on the POSIX subsystem of my operating system project, and I've reached the point where I would like to work on pthreads support. However, I'm not certain about the extent to which I should implement them.

What is the most-used pthreads functionality? Is there anything I could safely "just stub out" for now and implement it when we port an application that requires it? My research so far points to the basic thread operations (create, join, etc...) - that's quite obvious - and mutex support. Realistically speaking, do applications use much more than this?

I guess I'm just trying to figure out how little I can get away with while still having a working implementation.

like image 851
Matthew Iselin Avatar asked Aug 19 '09 07:08

Matthew Iselin


1 Answers

I'd suggest a bare bones pthread implementation cover the following functions (with "pthread_" prefixes removed):

  • basic thread operations
    create, exit, join, detach, self, equal, and "attr" support of joinability/detachability
  • process integration
    atfork, kill and sigmask
  • synchronization primitives
    cond and mutex functions (default attributes only -- nothing fancy!), possibly omitting cond_timedwait

Take a look at the SUSv6 entry on <pthread.h>, which I link in preference to SUSv7 because version 6 has more option groups called out in this header. I composed the above list by striking any optional features, and then dropping other sets of functionality that my personal history and observation suggest are inessential (e.g., thread-specific data) or both inessential and dangerous (e.g., thread cancellation). :)

like image 88
pilcrow Avatar answered Sep 30 '22 13:09

pilcrow