第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

作業(yè)社區(qū)

探索學(xué)習(xí)新天地,共享知識(shí)資源!

0 提交作業(yè)
0個(gè) 布置作業(yè)
0 滿分作業(yè)
得分 100
學(xué)習(xí)任務(wù)
得分 100
學(xué)習(xí)任務(wù)

jelasin 的學(xué)生作業(yè):

#ifndef __USE_GNU #define __USE_GNU #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include #include #include #include #include #include #include #include #include #include pid_t r_wait(int *stat_loc) { int retval; while(((retval = wait(stat_loc)) == -1 && (errno == EINTR))); return retval; } void sigaction_a(int sig, siginfo_t *si, void *uc) { fprintf(stderr, "Child process 1 received signal %s\n", strsignal(sig)); } int main() { pid_t child_pid[2]; cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(0, &cpuset); if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset) == -1) { perror("sched_setaffinity"); exit(EXIT_FAILURE); } child_pid[0] = fork(); if (child_pid[0] 0) { sched_yield(); // let child process 1 run child_pid[1] = fork(); if (child_pid[1] 0) { sched_yield(); // let child process 2 run fprintf(stderr, "Parent process sending SIGUSR1 to child 2\n"); if (sigqueue(child_pid[0], SIGUSR1, (union sigval){0}) == -1) { perror("sigqueue"); exit(EXIT_FAILURE); } fprintf(stderr, "Parent process sending SIGUSR2 to child 1\n"); if (sigqueue(child_pid[1], SIGUSR2, (union sigval){0}) == -1) { perror("sigqueue"); exit(EXIT_FAILURE); } int status; int cpid; while((cpid = r_wait(&status)) != -1) { continue; } if (errno != ECHILD) { perror("wait"); exit(EXIT_FAILURE); } } } return 0; } ? 5 ./main Child process 1 paused Child process 2 paused Parent process sending SIGUSR1 to child 2 Parent process sending SIGUSR2 to child 1 Child process 1 received signal User defined signal 1

得分 100
學(xué)習(xí)任務(wù)

jelasin 的學(xué)生作業(yè):

#ifndef __USE_GNU #define __USE_GNU #endif // CPU親和相關(guān)要定義這個(gè) #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include #include #include #include #include #include #include #include #include #include pid_t r_wait(int *stat_loc) { int retval; while(((retval = wait(stat_loc)) == -1 && (errno == EINTR))); return retval; } int main() { pid_t child_pid[2]; cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(0, &cpuset); if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset) == -1) { perror("sched_setaffinity"); exit(EXIT_FAILURE); } child_pid[0] = fork(); if (child_pid[0] < 0) { perror("fork #1"); exit(EXIT_FAILURE); } else if (child_pid[0] == 0) { fprintf(stderr, "Child process 1 paused\n"); pause(); } else if (child_pid[0] > 0) { sched_yield(); // let child process 1 run child_pid[1] = fork(); if (child_pid[1] < 0) { perror("fork #2"); exit(EXIT_FAILURE); } else if (child_pid[1] == 0) { fprintf(stderr, "Child process 2 raised SIGSTOP\n"); raise(SIGSTOP); } else if (child_pid[1] > 0) { sched_yield(); // let child process 2 run fprintf(stderr, "Parent process sending SIGCONT to child 2\n"); if (kill(child_pid[1], SIGCONT) == -1) { perror("kill"); exit(EXIT_FAILURE); } fprintf(stderr, "Parent process sending SIGTERM to child 1\n"); if (kill(child_pid[0], SIGTERM) == -1) { perror("kill"); exit(EXIT_FAILURE); } int status; int cpid; while((cpid = r_wait(&status)) != -1) { continue; } if (errno != ECHILD) { perror("wait"); exit(EXIT_FAILURE); } } } return 0; } ? 5 ./main Child process 1 paused Child process 2 raised SIGSTOP Parent process sending SIGCONT to child 2 Parent process sending SIGTERM to child 1 因?yàn)楦高M(jìn)程緩存多,現(xiàn)代Linux默認(rèn)父進(jìn)程先執(zhí)行,為了讓父進(jìn)程讓出cpu資源可以選擇讓父進(jìn)程sleep進(jìn)入就緒態(tài)。 更好的方案是使用sched_yield(),對(duì)于SMP來(lái)說(shuō),需要進(jìn)行綁核,以免父進(jìn)程讓出的CPU不是子進(jìn)程要搶占的CPU。

得分 100
討論題

阿大月 的學(xué)生作業(yè):

socket() 函數(shù)是網(wǎng)絡(luò)編程中的核心函數(shù)之一,用于創(chuàng)建一個(gè)新的套接字(socket),它允許程序通過(guò)網(wǎng)絡(luò)進(jìn)行通信。 #include #include int socket(int domain, int type, int protocol); 參數(shù)詳解 domain: 指定通信域或協(xié)議族(Protocol Family)。常見(jiàn)的值包括: AF_INET: IPv4 網(wǎng)絡(luò)協(xié)議。 AF_INET6: IPv6 網(wǎng)絡(luò)協(xié)議。 AF_UNIX: Unix 域套接字,用于同一臺(tái)主機(jī)上的進(jìn)程間通信。 type: 指定服務(wù)類型或套接字類型。常用的有: SOCK_STREAM: 提供有序、可靠、雙向的基于連接的字節(jié)流。(TCP) SOCK_DGRAM: 支持?jǐn)?shù)據(jù)報(bào)文(datagram)無(wú)連接通信。(UDP) SOCK_RAW: 提供原始網(wǎng)絡(luò)協(xié)議訪問(wèn)。 protocol: 指定使用的特定協(xié)議。通常設(shè)置為0,表示使用給定的 domain 和 type 的默認(rèn)協(xié)議。對(duì)于 AF_INET 和 SOCK_STREAM,默認(rèn)協(xié)議為 TCP;對(duì)于 AF_INET 和 SOCK_DGRAM,默認(rèn)協(xié)議為 UDP。 返回值 成功時(shí),socket() 返回一個(gè)文件描述符,該描述符指向新創(chuàng)建的套接字。如果發(fā)生錯(cuò)誤,則返回 -1 并設(shè)置全局變量 errno 來(lái)指示錯(cuò)誤類型。

微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)