中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

建設(shè)一個視頻網(wǎng)站友鏈提交入口

建設(shè)一個視頻網(wǎng)站,友鏈提交入口,sem優(yōu)化操作,網(wǎng)站開發(fā)下人員配置進程組 多個進程的集合,第一個進程就是組長,組長進程的PID等于進程組ID。 進程組生存期:進程組創(chuàng)建到最后一個進程離開(終止或轉(zhuǎn)移到另一個進程組)。與組長進程是否終止無關(guān)。 一個進程可以為自己或子進程設(shè)置進程組 ID 相關(guān)函數(shù) pid_t …

進程組

多個進程的集合,第一個進程就是組長,組長進程的PID等于進程組ID。

進程組生存期:進程組創(chuàng)建到最后一個進程離開(終止或轉(zhuǎn)移到另一個進程組)。與組長進程是否終止無關(guān)。

一個進程可以為自己或子進程設(shè)置進程組 ID

相關(guān)函數(shù)

pid_t getpgrp(void);
得到當(dāng)前進程所在的進程組的組 IDpid_t getpgid(pid_t pid);
獲取指定的進程所在的進程組的組 ID,參數(shù) pid 就是指定的進程,0當(dāng)前進程int setpgid(pid_t pid, pid_t pgid);
將某個進程移動到其他進程組中或者創(chuàng)建新的進程組參數(shù):pid: 某個進程的進程 IDpgid: 某個進程組的組 ID如果 pgid 對應(yīng)的進程組存在,pid 對應(yīng)的進程會移動到這個組中,pid != pgid如果 pgid 對應(yīng)的進程組不存在,會創(chuàng)建一個新的進程組,因此要求 pid == pgid, 當(dāng)前進程就是組長了返回值:函數(shù)調(diào)用成功返回 0,失敗返回 - 1

setpgid設(shè)置子進程組id

#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>int main(int argc, char *argv[])
{pid_t pid;pid = fork();if(pid == 0 ){printf("我是子進程:%d,我的進程組id是:%d\n",getpid(),getpgrp());setpgid(pid,pid);  //設(shè)置子進程的組id為自己的pid,默認是父進程的pidprintf("我是子進程:%d,我的進程組id是:%d\n",getpid(),getpgrp());}else if(pid > 0){sleep(1);printf("我是父進程:%d,我的進程組id是:%d\n",getpid(),getpgrp());wait(NULL);}return 0;
}

會話

多個進程組的集合

獲取進程所屬的會話 ID
pid_t getsid(pid_t pid); 
成功:返回調(diào)用進程的會話 ID;失敗:-1,設(shè)置 errno
pid 為 0 表示察看當(dāng)前進程 session ID創(chuàng)建一個會話,并以自己的 ID 設(shè)置進程組 ID,同時也是新會話的 ID。
pid_t setsid(void); 
成功:返回調(diào)用進程的會話 ID;失敗:-1,設(shè)置 errno
調(diào)用了 setsid 函數(shù)的進程,既是新的會長,也是新的組長。

注意事項:

調(diào)用進程不能是進程組組長,該進程變成新會話首進程(session header),建立新會話時,先調(diào)用 fork, 父進程終止,子進程調(diào)用 setsid(),
#include <stdio.h>
#include <unistd.h>int main(int argc, char *argv[])
{pid_t pid;pid = fork();if(pid == 0){printf("我是子進程id:%d,進程組id:%d,會話id:%d\n",getpid(),getpgid(0),getsid(0));printf("change--------------\n");sleep(2);setsid();printf("我是子進程id:%d,進程組id:%d,會話id:%d\n",getpid(),getpgid(0),getsid(0));}else{sleep(3);printf("我是父進程id:%d,進程組id:%d,會話id:%d\n",getpid(),getpgid(0),getsid(0));}return 0;
}

編譯執(zhí)行結(jié)果

我是子進程id:44801,進程組id:44800,會話id:39560  #默認子進程的進程組id是父進程的pid,會話id是當(dāng)前bash的pid
change--------------
我是子進程id:44801,進程組id:44801,會話id:44801  #setsid后,進程組id,會話id都變成子進程的pid
我是父進程id:44800,進程組id:44800,會話id:39560

守護進程

daemon進程。通常運行與操作系統(tǒng)后臺,脫離控制終端。一般不與用戶直接交互。周期性的等待某個事件發(fā)生或周期性執(zhí)行某一動作。

不受用戶登錄注銷影響。通常采用以d結(jié)尾的命名方式。

Linux 后臺的一些系統(tǒng)服務(wù)進程,沒有控制終端,不能直接和用戶交互。不受用戶登錄、注銷的影響,一直在運行著,他們都是守護進程。

創(chuàng)建守護進程

創(chuàng)建守護進程,最關(guān)鍵的一步是調(diào)用 setsid 函數(shù)創(chuàng)建一個新的 Session,并成為 Session Leader。

1. fork子進程,讓父進程終止。2. 子進程調(diào)用 setsid() 創(chuàng)建新會話3. 通常根據(jù)需要,改變工作目錄位置 chdir(), 防止目錄被卸載。4. 通常根據(jù)需要,重設(shè)umask文件權(quán)限掩碼,影響新文件的創(chuàng)建權(quán)限。  022 -- 755	0345 --- 432   r---wx-w-   4225. 通常根據(jù)需要,關(guān)閉/重定向 文件描述符6. 守護進程 業(yè)務(wù)邏輯。while()
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/time.h>
#include <string.h>void func(int signo)
{int fd1;fd1 = open("./lc.txt",O_RDWR|O_CREAT|O_APPEND,0664);  //fd1 = 3 符合默認的習(xí)慣if(fd1 == -1 ){perror("open lc.txt error");exit(1);}char *str="heppy new year\n";write(fd1,str,strlen(str));close(fd1);
}int main(int argc, char *argv[])
{pid_t pid;int fd,fd1;pid = fork();if(pid > 0){exit(1);}pid_t pid1 = setsid();if(pid1 == -1 ){perror("open lc.txt error");exit(1);}chdir("/home/lc");  //切換到一個不可能被刪除卸載的目錄umask(0022); //默認umask是0002,默認創(chuàng)建普通文件默認屬性是664close(STDIN_FILENO);  //close 0fd = open("/dev/null",O_RDWR);    //fd = 0if(fd == -1 ){perror("open /dev/null error");exit(1);}dup2(fd, STDOUT_FILENO); // 重定向 stdout和stderr  1 -->0dup2(fd, STDERR_FILENO); // 2--> 0,//捕捉信號struct sigaction act;act.sa_handler = func;act.sa_flags = 0;sigemptyset(&act.sa_mask);sigaction(SIGALRM,&act,NULL);
//      signal(SIGALRM,func);//設(shè)置定時器struct itimerval it;it.it_interval.tv_sec = 10;it.it_interval.tv_usec = 0;it.it_value.tv_sec = 10;it.it_value.tv_usec = 0;setitimer(ITIMER_REAL,&it,NULL);while (1);              // 模擬 守護進程業(yè)務(wù).return 0;
}

線程

LWP,(light weight process)輕量級的進程,在linux環(huán)境下線程的本質(zhì)仍然是進程,

進程:有獨立的 進程地址空間。有獨立的pcb。	分配資源的最小單位??煽闯墒侵挥幸粋€線程的進程線程:有獨立的pcb。沒有獨立的進程地址空間。	最小單位的執(zhí)行。
[root@lc133 ~]# ps -aux | grep mysql | grep -v grep
mysql      1620  0.4 20.2 1793004 405880 ?      Ssl  08:20   1:36 /usr/sbin/mysqld
Ssl:休眠,擁有子進程,多線程
[root@lc133 ~]# ps -Lf 1620
UID         PID   PPID    LWP  C NLWP STIME TTY      STAT   TIME CMD
mysql      1620      1   1620  0   38 08:20 ?        Ssl    0:01 /usr/sbin/mysqld
mysql      1620      1   1669  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1670  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1671  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1672  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1674  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1675  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1676  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1677  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1678  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1679  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1680  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1724  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1725  0   38 08:20 ?        Ssl    0:04 /usr/sbin/mysqld
mysql      1620      1   1726  0   38 08:20 ?        Ssl    0:04 /usr/sbin/mysqld
mysql      1620      1   1727  0   38 08:20 ?        Ssl    0:04 /usr/sbin/mysqld
mysql      1620      1   1728  0   38 08:20 ?        Ssl    0:04 /usr/sbin/mysqld
mysql      1620      1   1729  0   38 08:20 ?        Ssl    0:55 /usr/sbin/mysqld
mysql      1620      1   1786  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1787  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1788  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1793  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1794  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1797  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1799  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1802  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1803  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1804  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1811  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1812  0   38 08:20 ?        Ssl    0:05 /usr/sbin/mysqld
mysql      1620      1   1814  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1815  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1816  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1817  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1830  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1831  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1832  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqld
mysql      1620      1   1836  0   38 08:20 ?        Ssl    0:00 /usr/sbin/mysqldlwp:線程號

系統(tǒng)會給mysql進程1620分配進程地址空間,內(nèi)核空間擁有pid1620的pcb。

pid1620進程創(chuàng)建線程時,本身也成了主線程。創(chuàng)建的線程分別擁有自己獨立的pcb,處在同一內(nèi)核空間中。

線程更加節(jié)省系統(tǒng)資源,效率不僅可以保持的,而且能夠更高在一個地址空間中多個線程獨享:每個線程都有屬于自己的棧區(qū),寄存器 (內(nèi)核中管理的)1.線程 id2.處理器現(xiàn)場和棧指針(內(nèi)核棧)3.獨立的??臻g(用戶空間棧)4.errno 變量5.信號屏蔽字6.調(diào)度優(yōu)先級在一個地址空間中多個線程共享:代碼段,堆區(qū),全局數(shù)據(jù)區(qū),打開的文件 (文件描述符表) 都是線程共享的1.文件描述符表2.每種信號的處理方式3.當(dāng)前工作目錄4.用戶 ID 和組 ID5.內(nèi)存地址空間 (.text/.data/.bss/heap/共享庫)每個進程對應(yīng)一個虛擬地址空間,一個進程只能搶一個 CPU 時間片一個地址空間中可以劃分出多個線程,在有效的資源基礎(chǔ)上,能夠搶更多的 CPU 時間片一個進程創(chuàng)造線程并不是越多越好優(yōu)點: 1. 提高程序并發(fā)性 2. 開銷小 3. 數(shù)據(jù)通信、共享數(shù)據(jù)方便
缺點: 1. 庫函數(shù),不穩(wěn)定 2. 調(diào)試、編寫困難、gdb 不支持 3. 對信號支持不好
優(yōu)點相對突出,缺點均不是硬傷。Linux 下由于實現(xiàn)方法導(dǎo)致進程、線程差別不是很大。

pthread_self獲取當(dāng)前線程id

獲取線程 ID。其作用對應(yīng)進程中 getpid() 函數(shù)。pthread_t pthread_self(void);返回值:成功:0; 失敗:無!線程 ID:pthread_t 類型,本質(zhì):在 Linux 下為%lu無符號整數(shù),其他系統(tǒng)中可能是結(jié)構(gòu)體實現(xiàn)線程 ID 是進程內(nèi)部,識別標(biāo)志。(兩個進程間,線程 ID 允許相同)注意:在子線程中通過使用pthread_self,獲得線程id。

pthread_create創(chuàng)建線程

創(chuàng)建一個新線程。 其作用對應(yīng)進程中 fork() 函數(shù)。int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);返回值:成功:0; 失敗:錯誤號 -----Linux 環(huán)境下,所有線程特點,失敗均直接返回錯誤號。參數(shù):pthread_t:當(dāng)前 Linux 中可理解為:typedef unsigned long int pthread_t;參數(shù) 1:傳出參數(shù),保存系統(tǒng)為我們分配好的線程 ID參數(shù) 2:通常傳 NULL,表示使用線程默認屬性。若想使用具體屬性也可以修改該參數(shù)。參數(shù) 3:函數(shù)指針,指向線程主函數(shù)(線程體),該函數(shù)運行結(jié)束,則線程結(jié)束。參數(shù) 4:線程主函數(shù)執(zhí)行期間所使用的參數(shù)。傳參。

pthread_exit退出當(dāng)前線程

	void pthread_exit(void *retval);  退出當(dāng)前線程。參數(shù):線程退出的時候攜帶的數(shù)據(jù),當(dāng)前子線程的主線程會得到該數(shù)據(jù)。如果不需要使用,指定為 NULL幾個退出函數(shù):exit();	退出當(dāng)前進程。后續(xù)代碼不會執(zhí)行return: 返回到調(diào)用者那里去。pthread_exit(): 退出當(dāng)前線程。不影響其他進程

循環(huán)創(chuàng)建線程

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>void *func(void *arg)
{int i = (int)arg;printf("我是第%d子線程線程id:%lu,主線程是:%d\n",i+1,pthread_self(),getpid());//return NULL;if(i==4){while(1);}pthread_exit(NULL);
}int main(int argc, char *argv[])
{pthread_t tid;int i;for(i = 0; i < 5; i++){int ret = pthread_create(&tid,NULL,func,(void*)i);if(ret != 0){perror("pthread_create error");exit(1);}}//sleep(1);printf("我是主線程線程id:%lu,主線程是:%d\n",pthread_self(),getpid());//while(1);//return 0;pthread_exit(NULL);
}
主線程 pthread_exit(NULL);只退出當(dāng)先線程,不會對其他線程造成影響。
[lc@lc133 pthread]$ gcc pthread.c -lpthread
pthread.c: 在函數(shù)‘func’中:
pthread.c:8:10: 警告:將一個指針轉(zhuǎn)換為大小不同的整數(shù) [-Wpointer-to-int-cast]int i = (int)arg;^
pthread.c: 在函數(shù)‘main’中:
pthread.c:23:43: 警告:將一個整數(shù)轉(zhuǎn)換為大小不同的指針 [-Wint-to-pointer-cast]int ret = pthread_create(&tid,NULL,func,(void*)i);^
[lc@lc133 pthread]$ ./a.out
我是主線程線程id:140307387344704,主線程是:25356
我是第3子線程線程id:140307362223872,主線程是:25356
我是第2子線程線程id:140307370616576,主線程是:25356
我是第1子線程線程id:140307379009280,主線程是:25356
我是第4子線程線程id:140307353831168,主線程是:25356
我是第5子線程線程id:140307345438464,主線程是:25356
[root@lc133 ~]# ps -aux | grep a.out  #使用pthread_exit主線程已退出,子線程還在,使用return函數(shù),主線程退出,子進程也會退出
lc        25356  100  0.0      0     0 pts/1    Zl+  14:51   0:58 [a.out] <defunct>
root      25373  0.0  0.1 112840  2512 pts/0    S+   14:52   0:00 grep --color=auto a.out

pthread_join阻塞 回收線程

int pthread_join(pthread_t thread, void **retval);	阻塞 回收線程。thread: 待回收的線程idretval:傳出參數(shù)。 回收的那個線程的退出值。線程異常借助,值為 -1。返回值:成功:0失敗:errno

pthread_exit可以傳出指針,數(shù)值,要注意數(shù)據(jù)格式的強轉(zhuǎn)。

#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <stdlib.h>struct student
{int age;char name[256];
};void *func(void *arg)
{printf("child thread,process id is %d,thread id is %lu\n",getpid(),pthread_self());struct student *luci;luci = malloc(sizeof(struct student));memset(luci,0,sizeof(luci));luci->age = 17;strcpy(luci->name,"luci");pthread_exit((void *)luci);
}int main(int argc, char *argv)
{printf("main thread,process id is %d,thread id is %lu\n",getpid(),pthread_self());pthread_t tid;int ret = pthread_create(&tid,NULL,func,NULL);if(ret != 0){perror("pthread_creade error");exit(1);}struct student *retval;//pthread_join 傳出參數(shù)retval是void**類型的ret = pthread_join(tid,(void **)&retval);if(ret != 0){perror("pthread_jion error");exit(1);}printf("child thread exit.\n");printf("age = %d ,name = %s \n",retval->age,retval->name);return 0;
}
#include <stdio.h>
#include <pthread.h>void *func(void *arg)
{printf("child pthread id : %lu\n",pthread_self());pthread_exit((void*)66);
}int main(){pthread_t tid;int *retval;pthread_create(&tid,NULL,func,NULL);pthread_join(tid,(void**)&retval) ;printf("main pthread receive : %d\n",(void *)retval);pthread_exit(NULL);
}

pthread_detach 設(shè)置線程分離

	int pthread_detach(pthread_t thread);		設(shè)置線程分離thread: 待分離的線程id返回值:成功:0失敗:errno	
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <stdlib.h>void *func(void *arg)
{int i;for( i = 0;i < 5; i++){sleep(1);printf("i = %d \n",i);}pthread_exit(NULL);}
int main()
{pthread_t tid;int ret;ret = pthread_create(&tid,NULL,func,NULL);if(ret != 0){fprintf(stderr,"pthread_create error:%d",strerror(ret));exit(1);}pthread_detach(tid);ret = pthread_join(tid,NULL);//線程分離后主線程就不能回收了,報錯:無效的參數(shù)if(ret != 0){fprintf(stderr,"pthread_join error:%s",strerror(ret));exit(1);}pthread_exit(NULL);return 0;
}

pthread_cancel殺死一個線程

	int pthread_cancel(pthread_t thread);		殺死一個線程。  需要到達取消點(保存點)thread: 待殺死的線程id返回值:成功:0失敗:errno在線程 A 中調(diào)用線程取消函數(shù) pthread_cancel,指定殺死線程 B,這時候線程 B 是死不了的,只有在線程 B 中進程進行一次系統(tǒng)調(diào)用(從用戶區(qū)切換到內(nèi)核區(qū)),這個節(jié)點會被pthread_cancel殺死,否則線程 B 可以一直運行。與信號不同,進程會優(yōu)先處理信號。如果,子線程沒有到達取消點, 那么 pthread_cancel 無效。我們可以在程序中,手動添加一個取消點。使用 pthread_testcancel();成功被 pthread_cancel() 殺死的線程,返回 -1.使用pthead_join 回收。

pthread_equal判斷線程id是否相同

	int pthread_equal(pthread_t t1, pthread_t t2);參數(shù):t1 和 t2 是要比較的線程的線程 ID返回值:如果兩個線程 ID 相等返回非 0 值,如果不相等返回 0

與進程函數(shù)相比

	線程控制原語					進程控制原語pthread_create()				fork();pthread_self()					getpid();pthread_exit()					exit(); 		/ return pthread_join()					wait()/waitpid()pthread_cancel()				kill()pthread_detach()

創(chuàng)建線程時設(shè)置線程分離屬性

pthread_create函數(shù)中參數(shù) pthread_attr_t 是一個結(jié)構(gòu)體

typedef struct
{int                       detachstate;   // 線程的分離狀態(tài)int                       schedpolicy;   // 線程調(diào)度策略structsched_param         schedparam;    // 線程的調(diào)度參數(shù)int                       inheritsched;  // 線程的繼承性int                       scope;         // 線程的作用域size_t                    guardsize;     // 線程棧末尾的警戒緩沖區(qū)大小int                       stackaddr_set; // 線程的棧設(shè)置void*                     stackaddr;     // 線程棧的位置size_t                    stacksize;     // 線程棧的大小
} pthread_attr_t;
	步驟:pthread_attr_t attr  	創(chuàng)建一個線程屬性結(jié)構(gòu)體變量pthread_attr_init(&attr);	初始化線程屬性,成功:0;失敗:錯誤號pthread_attr_setdetachstate(&attr,  PTHREAD_CREATE_DETACHED);設(shè)置線程屬性為 分離態(tài)//detachstate: PTHREAD_CREATE_DETACHED(分離線程)//			  PTHREAD _CREATE_JOINABLE(非分離線程)//獲取程屬性,分離 or 非分離//int pthread_attr_getdetachstate(pthread_attr_t *attr, int *detachstate); //參數(shù): attr:已初始化的線程屬性pthread_create(&tid, &attr, tfn, NULL); 借助修改后的 設(shè)置線程屬性 創(chuàng)建為分離態(tài)的新線程pthread_attr_destroy(&attr);	銷毀線程屬性,成功:0;失敗:錯誤號
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>void *func(void *arg)
{printf("hello wrold.\n");pthread_exit(NULL);
}int main()
{pthread_attr_t attr;pthread_attr_init(&attr);pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);int val;pthread_attr_getdetachstate(&attr,&val);printf("屬性:%d\n",val);pthread_t tid;pthread_create(&tid,&attr,func,NULL);pthread_attr_destroy(&attr);sleep(1);int ret = pthread_join(tid,NULL);if(ret != 0){fprintf(stderr,"pthread_join error : %s\n",strerror(ret));exit(1);}pthread_exit(NULL);return 0;
}
[lc@lc pthread]$ ./a.out
屬性:1
hello wrold.
pthread_join error : Invalid argument
//pthread_join報錯成功分離

注意事項

1. 主線程退出其他線程不退出,主線程應(yīng)調(diào)用 pthread_exit
2. 避免僵尸線程
pthread_join
pthread_detach
pthread_create 指定分離屬性
被 join 線程可能在 join 函數(shù)返回前就釋放完自己的所有內(nèi)存資源,所以不應(yīng)當(dāng)返回被回收線程棧中的值;
3. malloc 和 mmap 申請的內(nèi)存可以被其他線程釋放
4. 應(yīng)避免在多線程模型中調(diào)用 fork 除非,馬上 exec,子進程中只有調(diào)用 fork 的線程存在,其他線程在子進程
中均 pthread_exit
5. 信號的復(fù)雜語義很難和多線程共存,應(yīng)避免在多線程引入信號機制
http://www.risenshineclean.com/news/48775.html

相關(guān)文章:

  • 移動互聯(lián)網(wǎng)網(wǎng)站建設(shè)廣告宣傳費用一般多少
  • 鞋子 東莞網(wǎng)站建設(shè)營銷軟件代理推廣
  • 網(wǎng)站的制作優(yōu)化網(wǎng)站收費標(biāo)準(zhǔn)
  • 青浦網(wǎng)絡(luò)公司網(wǎng)站官方推廣平臺
  • 皇崗網(wǎng)站建設(shè)成都自然排名優(yōu)化
  • 備案 手機網(wǎng)站專門做推廣的軟文
  • 專業(yè)做網(wǎng)站設(shè)計公司價格新網(wǎng)站如何推廣
  • 網(wǎng)站優(yōu)化主要工作有那些內(nèi)容的磁力搜索引擎
  • 網(wǎng)站底部怎么做需要放些什么獨立站建站需要多少錢
  • 北京虛擬注冊地址新政中國seo公司
  • 專門教ps的網(wǎng)站千峰培訓(xùn)可靠嗎?
  • 橙子官方網(wǎng)站友鏈申請
  • 學(xué)術(shù)網(wǎng)站怎么做百度關(guān)鍵詞seo
  • php企業(yè)網(wǎng)站源碼藍色湖南seo網(wǎng)站策劃
  • 網(wǎng)站設(shè)計用什么軟件做的懷化網(wǎng)站seo
  • 酷炫網(wǎng)站推薦如何讓網(wǎng)站被百度收錄
  • 個人做網(wǎng)站需要注意什么seo 優(yōu)化
  • 有什么做節(jié)能報告的網(wǎng)站福州網(wǎng)站建設(shè)
  • v9網(wǎng)站模板網(wǎng)頁怎么制作
  • 東莞智通人才網(wǎng)招聘信息網(wǎng)windows優(yōu)化軟件
  • 網(wǎng)站鏈接改名怎做301sem 優(yōu)化價格
  • 做畫冊封面的網(wǎng)站快速排序優(yōu)化
  • 中國建設(shè)網(wǎng)站企業(yè)網(wǎng)上銀行業(yè)務(wù)功能0元入駐的電商平臺
  • java答題對戰(zhàn)網(wǎng)站開發(fā)巨量廣告投放平臺
  • 電腦系統(tǒng)做的好的網(wǎng)站百度app客服電話
  • 青島高端網(wǎng)站開發(fā)廚師培訓(xùn)機構(gòu) 廚師短期培訓(xùn)班
  • 有哪些h5做的網(wǎng)站怎么卸載windows優(yōu)化大師
  • wordpress多站點sitemap免費建站網(wǎng)站大全
  • 360網(wǎng)站攔截做韶關(guān)新聞最新今日頭條
  • 網(wǎng)站建設(shè)預(yù)算策劃百度seo霸屏軟件