CSCI 375 Homework #2

.pdf

School

CUNY John Jay College of Criminal Justice *

*We aren’t endorsed by this school

Course

380

Subject

Computer Science

Date

May 11, 2024

Type

pdf

Pages

4

Uploaded by SargentBatPerson1055 on coursehero.com

Nicholas Reyes CSCI 375- February 24, 2024 Homework #2 (Due by Feb 29, 2024): Exercise Problems for Chapter 3 (3.1 ~ 3.5), Chapter 4 (4.1 ~ 4.6) 3.1 Using the program shown in Figure 3.30, explain what the output will be at LINE A. The parent value for “LINE A” would have an output of 5. The child “value” initially starts off as 5 in the beginning of the code used in figure 3.30. Later on it adds 15, then finishes its job by returning 0. The parent function waits until the child function is finished in order to execute itself due to the “wait (NULL)” function. The parent does not change the value of “value” so then “LINE A” returns 5. 3.2 Including the initial parent process, how many processes are created by the program shown in Figure 3.31? The answer is 8 processes are created by the program shown in figure 3.3. Each individual fork() system call creates a new process which splits into two. The answer would be 7 but the question says to include the initial parent process so that would make it 8. 3.3 Original versions of Apple’s mobile iOS operating system provided no means of concurrent processing. Discuss three major complications that concurrent processing adds to an operating system. Some of the problems that concurrent processing adds to an operating system is that switching from one process to the next is time consuming, this requires for the current values to be saved for the initial process and then the values of the next process to be loaded. Another complication that becomes evident is if the next process requires a large amount of memory space then the current process would need to be moved back to the hard disk in order to make room for the switch, which again is time consuming. And another complication would be 3.4 Some computer systems provide multiple register sets. Describe what happens when a context switch occurs if the new context is already loaded into one of the register sets. What happens if the new context is in memory rather than in a register set and all the register sets are in use? If the new context is already loaded into one of the register set, the current register set pointer is simply changed to point towards the set containing the new context.
If the new context happens to be in memory rather than in a register set and all the registers are in use, then one of the contexts in the current register sets that are in use have to be moved into the memory in order for it to take its spot. This takes a little bit more time then if it were to already be loaded into one of the register sets. 3.5 When a process creates a new process using the fork() operation, which of the following states is shared between the parent process and the child process? a. Stack b. Heap c. Shared memory segments The answer is Shared memory segments. Only the memory segments would be shared between the parent process and the child process because they both access the same memory in order to perform their tasks. 4.1 Provide three programming examples in which multithreading provides better performance than a single-threaded solution. 1. A web server that serves each requests in separate threads 2. Matrix multiplication where multiple parts of the matrix can be worked on at the same time 3. A debugger where one thread is used to monitor user input, another thread runs the application and another monitors the errors 4.2 Using Amdahl’s Law, calculate the speedup gain of an application that has a 60 percent parallel component for (a) two processing cores (b) four processing cores. a. With two processing cores we get a speedup of 1.42 times. S = 40% N = 2 Speedup = 1/((S)+(1-S/N)) =1/((0.40)+(0.60/2))=1/0.70=1.42
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help