What could be an issue with the following program? Assume the child process is executed immediately after forked. int main() { int pid=fork(); if(pid < 0) exit(1); if(pid == 0) { printf("hello world\n"); } else if(pid > 0) { sleep(100000) ; } return 0; } Select one: a. It may create a zombie process. b. It may cause other processes to starve by hogging CPU time executing sleep. c. It may create an orphan process.
Question
What could be an issue with the following program? Assume the child process is executed immediately after forked.
int main() { int pid=fork(); if(pid < 0) exit(1); if(pid == 0) { printf("hello world\n"); } else if(pid > 0) { sleep(100000) ; } return 0; }
Select one:
a. It may create a zombie process.
b. It may cause other processes to starve by hogging CPU time executing sleep.
c. It may create an orphan process.
Solution
所选择的文本的语言是英语。
Similar Questions
Consider the following fragment of a program: ... int a=0; int main() { a = 1; int pid=fork(); if(pid == 0) { printf("%d\n", a); } else if(pid > 0) { printf("%d\n", a); } return 0; } When run, what output do you observe and what do you think is the reason for the observed output? You may assume that the call to fork() succeeds. Question 4 Select one: a. The parent process outputs 1, but the child process outputs 0, because the value of a is updated only in the parent process. b. Both the parent and the child processes output 1, because the child process inherits the memory state from the parent at the point where fork() is called, and the variable a has been assigned the value 1 at that point. c. The parent process outputs 0, but the child process outputs 1, because the value of a is updated only in the child process.
Are you creating user-level or kernel-level threads? How do you know?2. In what ways is this program easier to implement using threads, rather than forking two child processes?3. In what ways is this program more difficult to implement by using threads rather than forking two child processes?4. What could occur if you added the two threads' results without joining with them first?5. Why did you not need to add mutexes or other locking construct to your program, despite it being multithreaded?
if a thread in a program invokes exec() immediately after fork() . So-------Select one:a. duplicates only calling thread is appropriateb. duplicates all threads in a separate process
Which of the following system calls is used to create a new process in Unix-like operating systems? (A) fork() (B) exec() (C) create() (D) spawn() (E) process()
Write a program which creates a child process and the parent processwaits for the child process to exit after printing the process id of the child andparent process. (Use: fork, wait, getpid, getppid, exit System Calls)
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.