Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Process and threads are mechanisms to realize concurrency in operating systems. Answer the following questions. (a) Using the concept of Process Control Block, contrast
Process and threads are mechanisms to realize concurrency in operating systems. Answer the following questions. (a) Using the concept of Process Control Block, contrast the concept of process and the concept of thread. (b) In relation to your answer to question 4a, describe what output you would observe and what would happen in the OS kernel in terms of process, thread, and process control blocks if you run the following program (the include lines are left out). const int STACK_SIZE = 1024 1024; 2int value = 0; 4int runner (void *param) { 5 value 7310; return 0; 7} sint main(int argc, char *argv[]) { stackTop; 9 10 11 12 13 14 15 16 24 25 char *stack, pid t pid, cpid; pid fork(); 17 printf("CHILD(pid-%d):value%d ", getpid (), value); 18 cpid clone (runner, stackTop, CLONE_VMI SIGCHLD, NULL); 19 printf("CHILD(pid=%d):value=%d ", getpid (), value); waitpid (cpid, NULL, 0);: 20 21 printf("CHILD(pid=%d):value=%d ", getpid (), value); 22 27 28 29 30 31} stack = malloc (STACK_SIZE); stackTop stack + STACK_SIZE; if (pid == 0) { } else if (pid > 0) { printf ("PARENT (pid=%d) value%d ", getpid (), value); cpid clone (runner, stackTop, SIGCHLD, NULL); printf ("PARENT (pid=%d):value%d ", getpid (), value); waitpid (cpid, NULL, 0); } wait (NULL); printf ("PARENT (pid=%d): value%d ", getpid (), value); (c) Explain the purpose of the two lines 13-14 in the above code, and why we write them in such a way.
Step by Step Solution
★★★★★
3.48 Rating (158 Votes )
There are 3 Steps involved in it
Step: 1
a The concept of a process and the concept of a thread both relate to concurrency in operating systems but they differ in several ways which can be contrasted using the concept of a Process Control Bl...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started