Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock

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... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Operating System Questions!