Answered step by step
Verified Expert Solution
Link Copied!

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

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Management Science A Modeling And Cases Studies Approach With Spreadsheets

Authors: Frederick S. Hillier, Mark S. Hillier

5th Edition

978-0077825560, 78024064, 9780077498948, 007782556X, 77498941, 978-0078024061

More Books

Students also viewed these Operating System questions

Question

In Exercises, find the limit. lim 5 x 0-x 813 X

Answered: 1 week ago

Question

1. How does the idea of allostasis differ from homeostasis?

Answered: 1 week ago