[作業] 4/8 作業系統

看板CHU_CS96b作者 (河馬)時間15年前 (2010/03/30 20:16), 編輯推噓2(201)
留言3則, 3人參與, 最新討論串1/1
(3.5) Describe the actions taken by a kernel to context-switch between process. (3.9) Describe the differences among short-term, medium-term, and long-term scheduling. (3.10) #include <stdio.h> #include <unistd.h> int main() { /*fork a child process */ fork(); /*fork another child process */ fork(); /*and fork another */ fork(); return 0; } How many process are created? (3.11) #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main() { pid_t pid, pid1; /*fork a child process */ pid=fork(); if(pid<0) {/*error occurred */ fprintf(stderr, "Fork Failed"); return 1; } else if(pid==0){/*child process */ pid1=getpid(); printf("child: pid=%d ",pid); /*A*/ printf("child: pid1=%d ",pid1); /*B*/ } else {/*parent process */ pid1=getpid(); printf("parent: pid=%d ",pid); /*C*/ printf("parent: pid1=%d ",pid1); /*D*/ wait(NULL); } return 0; } What are the pid values? 至於如何跑程式...舉例說明 首先連到工作站 然後打vim OS.c 按i就可以編輯文件 把複製的程式碼按右鍵,就會貼上去 按ESC,再輸入:wq 就會存檔離開 gcc OS.c -o OS_HW,這是在做編譯 OS_HW是編譯過的檔案 ./OS_HW 來執行程式 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.43.197.143

03/30 20:18, , 1F
GJ~~
03/30 20:18, 1F

03/30 23:14, , 2F
已完成 感謝大大無私分享 好的分享值得一推再推
03/30 23:14, 2F

03/31 02:03, , 3F
感謝樓上提供題目xd
03/31 02:03, 3F
文章代碼(AID): #1BiUkuk- (CHU_CS96b)