Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

202109/CST306/A

Question 1 (30 marks)

The getpid(), fork(), wait () and exec() system calls are the major system calls involving userspace process in Linux OS. Note that the execvp() system call is used to execute (i.e run) a program apart from the calling program.

Construct  a  C  program  producing  the  following  output  (Figure  1)  and  satisfying  the following conditions:

a. A parent process is created

b. A child process is created.

c. The created child process in b. above shall execute a program that compares the contents of two strings in a text file. Name this program compare.

 

Figure 1

Question 2  (55 marks)

Construct two 16 KB user space process memory address spaces of: one single thread and two threads.

(15 marks)

Next, create a C code which produces the output in Figure 2. The conditions to be satisfied by your C code are as follows:

a.   Two threads A and B, are created.

b.   A and B are to update a global shared variable, counter = 100.

(40 marks)

 

Figure 2

Question 3 (15 marks)

Construct a table and briefly discuss the strengths and weakness of the following memory management techniques for scheduling processes in user space memory: fixed and dynamic partitioning.

(6 marks)

Using buddy system, segment a 64 kB memory in order to accommodate a 4 KB process in a 5 KB memory block. Construct a diagram to clearly illustrate the segmentation process.

(9 marks)