Question: Operating Systems ( Homework #1) NOTE: Please provide a hand written solution . A soft copy or computer printed version will not be accepted. You

Operating Systems (Homework #1)

NOTE: Please provide a hand written solution. A soft copy or computer printed version will not be accepted. You must submit ONE copy of homework per group.

Q1 (50):

a) What does an operating system do? Why do we need it?
b) What is an interrupt vector? Why is it needed? How is it used during interrupt processing?
c) Why does invoking a system call cause the system to change mode from user mode to kernel mode? Explain.
d) Why do we store CPU state (program counter and registers) in process control block? Explain.
e) What is the difference between orphan and zombie processes? Please explain.

Q2(30): Please draw the memory layout of all the process created by the following program when the process is at LINE A. Explicitly show all the memory regions (text, data, stack and heap) for each process and display the variables and their respective values as stored in each region.

Also, what will be printed on the screen at the end of this program?

#include

#include

#include

int SIZE = 4;

int k=10;

void printIt(int *m) {

int i=0;

for (i=0; i

printf("%d,",m[i]);

}

printf(" ");

// LINE A

}

void increment(int* a, int divider) {

int i=0;

for (i=0; i

if (a[i]%divider==0) {

a[i]++;

}

}

printIt(a);

}

void compute(int p) {

int* c = (int *)malloc(sizeof(int)*SIZE);

c[0]=10; c[1]=12; c[2]=11; c[3]=18;

increment(c, p);

}

void main() {

compute(3);

}

Q3 (20): Please draw the memory representation of all the processes created by running the following program when both processes are at LINE A? Explicitly show all the memory regions (text, data, stack and heap) for each process and display the variables and their respective values as stored in each region.

Also, what will be printed by this program on the screen when all the processes are finished?

#include

#include

#include

void foo(int p) {

p++;

// LINE A

}

void main() {

pid_t pid;

int k=600;

int m=100;

pid = fork();

k++;

if (pid==0) {

k++;

m++;

foo(m);

printf("child process:k=%d,m=%d ",k,m);

}

else {

foo(m);

printf("parent process waiting for child ... ");

wait(NULL);

printf("parent process:k=%d,m=%d ",k,m);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 General Management Questions!