mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Make some fixups to POSIX threads
This commit is contained in:
parent
de511bc71a
commit
6c323383e5
12 changed files with 168 additions and 69 deletions
|
@ -10,10 +10,46 @@ COSMOPOLITAN_C_START_
|
|||
* @fileoverview Cosmopolitan POSIX Thread Internals
|
||||
*/
|
||||
|
||||
// LEGAL TRANSITIONS ┌──> TERMINATED
|
||||
// pthread_create ─┬─> JOINABLE ─┴┬─> DETACHED ──> ZOMBIE
|
||||
// └──────────────┘
|
||||
enum PosixThreadStatus {
|
||||
|
||||
// this is a running thread that needs pthread_join()
|
||||
//
|
||||
// the following transitions are possible:
|
||||
//
|
||||
// - kPosixThreadJoinable -> kPosixThreadTerminated if start_routine()
|
||||
// returns, or is longjmp'd out of by pthread_exit(), and the thread
|
||||
// is waiting to be joined.
|
||||
//
|
||||
// - kPosixThreadJoinable -> kPosixThreadDetached if pthread_detach()
|
||||
// is called on this thread.
|
||||
kPosixThreadJoinable,
|
||||
|
||||
// this is a managed thread that'll be cleaned up by the library.
|
||||
//
|
||||
// the following transitions are possible:
|
||||
//
|
||||
// - kPosixThreadDetached -> kPosixThreadZombie if start_routine()
|
||||
// returns, or is longjmp'd out of by pthread_exit(), and the thread
|
||||
// is waiting to be joined.
|
||||
kPosixThreadDetached,
|
||||
|
||||
// this is a joinable thread that terminated.
|
||||
//
|
||||
// the following transitions are possible:
|
||||
//
|
||||
// - kPosixThreadTerminated -> _pthread_free() will happen when
|
||||
// pthread_join() is called by the user.
|
||||
kPosixThreadTerminated,
|
||||
|
||||
// this is a detached thread that terminated.
|
||||
//
|
||||
// the following transitions are possible:
|
||||
//
|
||||
// - kPosixThreadZombie -> _pthread_free() will happen whenever
|
||||
// convenient, e.g. pthread_create() entry or atexit handler.
|
||||
kPosixThreadZombie,
|
||||
};
|
||||
|
||||
|
@ -28,11 +64,11 @@ struct PosixThread {
|
|||
pthread_attr_t attr;
|
||||
};
|
||||
|
||||
void pthread_free(struct PosixThread *) hidden;
|
||||
void pthread_wait(struct PosixThread *) hidden;
|
||||
void pthread_zombies_add(struct PosixThread *) hidden;
|
||||
void pthread_zombies_decimate(void) hidden;
|
||||
void pthread_zombies_harvest(void) hidden;
|
||||
void _pthread_free(struct PosixThread *) hidden;
|
||||
void _pthread_wait(struct PosixThread *) hidden;
|
||||
void _pthread_zombies_add(struct PosixThread *) hidden;
|
||||
void _pthread_zombies_decimate(void) hidden;
|
||||
void _pthread_zombies_harvest(void) hidden;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue