Home | History | Annotate | Line # | Download | only in libpthread
README revision 1.1
      1  1.1  proven This pthread package is/will be based on the POSIX1003.4a Draft 7 pthread
      2  1.1  proven standard, and Frank Mullers paper on signal handelling presented
      3  1.1  proven at the Winter 93 USENIX conference.
      4  1.1  proven 
      5  1.1  proven It is currently being designed and written by me, Chris Provenzano.
      6  1.1  proven All bug, comments, and questions can be sent me at either
      7  1.1  proven proven (a] athena.mit.edu or proven (a] sun-lamp.cs.berkeley.edu
      8  1.1  proven Please don't send bugs or patches to any of the NetBSD mailing lists.
      9  1.1  proven 
     10  1.1  proven Thanks goes to John Carr jfc (a] mit.edu for porting this to the IBM/RT,
     11  1.1  proven and for his bug reports and fixes.
     12  1.1  proven 
     13  1.1  proven PORTING
     14  1.1  proven One of the goals of this user space implementation of pthreads is that it
     15  1.1  proven be portable. I have minimized the ammount of assembler code necessary,
     16  1.1  proven but some is.
     17  1.1  proven 
     18  1.1  proven If you want to port it to another platform here are a few basic hints.
     19  1.1  proven 
     20  1.1  proven There are currently three files you'll have to creat for your
     21  1.1  proven architecture, machdep.h, machdep.c and syscall.S.
     22  1.1  proven The first two are necessary to get the context switch section of
     23  1.1  proven the pthread package running, the third is for all the syscalls.
     24  1.1  proven 
     25  1.1  proven To do an initial port, create an appropriate machdep.h, and machdep.c
     26  1.1  proven and define PTHREAD_INITIAL_PORT in the Makefile
     27  1.1  proven 
     28  1.1  proven Comment out references to the stdio package.
     29  1.1  proven 
     30  1.1  proven INCLUDE FILES AND PORTING
     31  1.1  proven To continue to make this package portable, some basic rules on includes
     32  1.1  proven files must be followed.
     33  1.1  proven 
     34  1.1  proven pthread.h should be included first (if it is to be included).
     35  1.1  proven machdep.h should define size_t if the system doesn't define it already
     36  1.1  proven 
     37  1.1  proven stdio.h should not be included. It is included in pthread.h.
     38  1.1  proven 
     39  1.1  proven posix.h should be included last. This file is used to correct non
     40  1.1  proven POSIX features, after everything else has been defined.
     41  1.1  proven 
     42  1.1  proven INTERNAL LOCKING
     43  1.1  proven To prevent deadlocks the following rules were used for locks.
     44  1.1  proven 
     45  1.1  proven 1.	Local locks for mutex queues and other like things are only locked
     46  1.1  proven 	by running threads, at NO time will a local lock be held by
     47  1.1  proven 	a thread in a non running state.
     48  1.1  proven 2.  Only threads that are in a run state can attempt to lock another thread,
     49  1.1  proven 	this way, we can assume that the lock will be released shortly, and don't
     50  1.1  proven 	have to unlock the local lock.
     51  1.1  proven 3.	The only time a thread will have a pthread->lock and is not in a run
     52  1.1  proven 	state is when it is in the reschedule routine.
     53  1.1  proven 4.	The reschedule routine assumes all local locks have been released,
     54  1.1  proven 	there is a lock on the currently running thread (pthread_run),
     55  1.1  proven 	and that this thread is being rescheduled to a non running state.
     56  1.1  proven 	It is safe to unlock the currently running threads lock after it
     57  1.1  proven 	has been rescheduled.
     58  1.1  proven 5.	The reschedule routine locks the kernel, sets the state of the currently
     59  1.1  proven 	running thread, unlocks the currently running thread, calls the
     60  1.1  proven 	context switch routines.
     61  1.1  proven 6	the kernel lock is used only ...
     62  1.1  proven 
     63  1.1  proven 
     64  1.1  proven 7.	The order of locking is ...
     65  1.1  proven 
     66  1.1  proven 1 local locks
     67  1.1  proven 2 pthread->lock			/* Assumes it will get it soon */
     68  1.1  proven 3 pthread_run->lock		/* Assumes it will get it soon, but must release 2 */
     69  1.1  proven 4 kernel lock			/* Currently assumes it will ALWAYS get it. */
     70  1.1  proven 
     71  1.1  proven 8.	The kernel lock will be changed to a spin lock for systems that
     72  1.1  proven already support kernel threads, this way we can mutiplex threads onto
     73  1.1  proven kernel threads.
     74  1.1  proven 9.	There are points where the kernel is locked and it needs to get
     75  1.1  proven either a local lock or a pthread lock, if at these points the code
     76  1.1  proven fails to get the lock the kernel gives up and sets a flag which will
     77  1.1  proven be checked at a later point.
     78  1.1  proven 10.	Interrupts are dissabled while the kernel is locked, the interrupt
     79  1.1  proven mask must be checked afterwards or cleared in some way, after interrputs
     80  1.1  proven have been reenabled, this allows back to back interrupts, but should always
     81  1.1  proven avoid missing one.
     82  1.1  proven 
     83  1.1  proven Copyright (c) 1993 Chris Provenzano. All rights reserved.
     84  1.1  proven 
     85  1.1  proven This product includes software developed by the Univeristy of California,
     86  1.1  proven Berkeley and its contributors.
     87