資源簡介
posix linux環(huán)境下的pthread source 通過查看源代碼可以對線程的認(rèn)識更加深刻 你知道嗎?線程的底層實(shí)現(xiàn)也是調(diào)用clone[創(chuàng)建進(jìn)程] 故有線程是輕量級的進(jìn)程

代碼片段和文件信息
/*?Copyright?(C)?2002-2013?Free?Software?Foundation?Inc.
???This?file?is?part?of?the?GNU?C?Library.
???Contributed?by?Ulrich?Drepper??2002.
???The?GNU?C?Library?is?free?software;?you?can?redistribute?it?and/or
???modify?it?under?the?terms?of?the?GNU?Lesser?General?Public
???License?as?published?by?the?Free?Software?Foundation;?either
???version?2.1?of?the?License?or?(at?your?option)?any?later?version.
???The?GNU?C?Library?is?distributed?in?the?hope?that?it?will?be?useful
???but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
???MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the?GNU
???Lesser?General?Public?License?for?more?details.
???You?should?have?received?a?copy?of?the?GNU?Lesser?General?Public
???License?along?with?the?GNU?C?Library;?if?not?see
??? .??*/
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#ifndef?NEED_SEPARATE_REGISTER_STACK
/*?Most?architectures?have?exactly?one?stack?pointer.??Some?have?more.??*/
#?define?STACK_VARIABLES?void?*stackaddr?=?NULL
/*?How?to?pass?the?values?to?the?‘create_thread‘?function.??*/
#?define?STACK_VARIABLES_ARGS?stackaddr
/*?How?to?declare?function?which?gets?there?parameters.??*/
#?define?STACK_VARIABLES_PARMS?void?*stackaddr
/*?How?to?declare?allocate_stack.??*/
#?define?ALLOCATE_STACK_PARMS?void?**stack
/*?This?is?how?the?function?is?called.??We?do?it?this?way?to?allow
???other?variants?of?the?function?to?have?more?parameters.??*/
#?define?ALLOCATE_STACK(attr?pd)?allocate_stack?(attr?pd?&stackaddr)
#else
/*?We?need?two?stacks.??The?kernel?will?place?them?but?we?have?to?tell
???the?kernel?about?the?size?of?the?reserved?address?space.??*/
#?define?STACK_VARIABLES?void?*stackaddr?=?NULL;?size_t?stacksize?=?0
/*?How?to?pass?the?values?to?the?‘create_thread‘?function.??*/
#?define?STACK_VARIABLES_ARGS?stackaddr?stacksize
/*?How?to?declare?function?which?gets?there?parameters.??*/
#?define?STACK_VARIABLES_PARMS?void?*stackaddr?size_t?stacksize
/*?How?to?declare?allocate_stack.??*/
#?define?ALLOCATE_STACK_PARMS?void?**stack?size_t?*stacksize
/*?This?is?how?the?function?is?called.??We?do?it?this?way?to?allow
???other?variants?of?the?function?to?have?more?parameters.??*/
#?define?ALLOCATE_STACK(attr?pd)?\
??allocate_stack?(attr?pd?&stackaddr?&stacksize)
#endif
/*?Default?alignment?of?stack.??*/
#ifndef?STACK_ALIGN
#?define?STACK_ALIGN?__alignof__?(long?double)
#endif
/*?Default?value?for?minimal?stack?size?after?allocating?thread
???descriptor?and?guard.??*/
#ifndef?MINIMAL_REST_STACK
#?define?MINIMAL_REST_STACK 4096
#endif
/*?Newer?kernels?have?the?MAP_STACK?flag?to?indica
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-11-14?18:44??nptl\
?????文件????????2545??2013-11-14?16:43??nptl\ANNOUNCE
?????文件??????????54??2013-11-14?16:43??nptl\Banner
?????文件??????520054??2013-11-14?16:43??nptl\ChangeLog
?????文件?????????982??2013-11-14?16:43??nptl\DESIGN-barrier.txt
?????文件????????2235??2013-11-14?16:43??nptl\DESIGN-condvar.txt
?????文件????????2731??2013-11-14?16:43??nptl\DESIGN-rwlock.txt
?????文件?????????835??2013-11-14?16:43??nptl\DESIGN-sem.txt
?????文件????????3981??2013-11-14?16:43??nptl\DESIGN-systemtap-probes.txt
?????文件????????1286??2013-11-14?16:43??nptl\Makeconfig
?????文件???????24675??2013-11-14?16:43??nptl\Makefile
?????文件????????1038??2013-11-14?16:43??nptl\TODO
?????文件?????????588??2013-11-14?16:43??nptl\TODO-kernel
?????文件?????????295??2013-11-14?16:43??nptl\TODO-testing
?????文件????????8157??2013-11-14?16:43??nptl\Versions
?????文件????????1450??2013-11-14?16:43??nptl\alloca_cutoff.c
?????文件???????36671??2013-11-14?16:43??nptl\allocatestack.c
?????文件????????2946??2013-11-14?16:43??nptl\cancellation.c
?????文件????????1726??2013-11-14?16:43??nptl\cleanup.c
?????文件????????1788??2013-11-14?16:43??nptl\cleanup_compat.c
?????文件????????2950??2013-11-14?16:43??nptl\cleanup_defer.c
?????文件????????3058??2013-11-14?16:43??nptl\cleanup_defer_compat.c
?????文件????????1032??2013-11-14?16:43??nptl\cleanup_routine.c
?????文件????????2153??2013-11-14?16:43??nptl\cond-perf.c
?????文件?????????399??2013-11-14?16:43??nptl\configure
?????文件???????13281??2013-11-14?16:43??nptl\descr.h
?????文件????????2179??2013-11-14?16:43??nptl\eintr.c
?????文件??????????13??2013-11-14?16:43??nptl\elision-conf.h
?????文件??????????31??2013-11-14?16:43??nptl\errno-loc.c
?????文件????????1117??2013-11-14?16:43??nptl\events.c
?????文件????????7923??2013-11-14?16:43??nptl\forward.c
............此處省略928個文件信息
評論
共有 條評論