Question: Suppose the hypothetical processor of Figure 1.3 also has two I/O instructions: (15 points) 0011 = Load AC from I/O 0111 = Store AC to

  1. Suppose the hypothetical processor of Figure 1.3 also has two I/O instructions: (15 points)

0011 = Load AC from I/O

0111 = Store AC to I/O

In these cases, the 12-bit address identifies a particular external device. Show the program execution (using format of Figure 1.4) for the following program:

1. Load AC from device 5.

2. Add contents of memory location 940.

3. Store AC to device 4.

Assume that the next value retrieved from device 5 is 6 and that location 940 contains a value of 3.

 Suppose the hypothetical processor of Figure 1.3 also has two I/Oinstructions: (15 points) 0011 = Load AC from I/O 0111 = Store

  1. A system adopts a priority-based preemptive scheduling where the initial priority of a process increases by 1 after every 5ms. In a recorded time span, the system has four processes P1, P2, P3, P4 as shown in the following table: (10 points)

Process ID

Initial Priority

Arrival Time in ms

Total CPU time in ms

P1

1

0

15

P2

3

5

7.5

P3

2

10

5

P4

2

15

10

Draw a timing diagram similar to Fig 3.7 and find the turnaround time for each process. Assume that the dispatcher takes 2.5ms for a process switch.

AC to I/O In these cases, the 12-bit address identifies a particular

  1. Write a multithreaded program that calculates various statistical values for a list of numbers. This program will be passed a series of numbers on the command line and will then create three separate worker threads. One thread will determine the average of the numbers, the second will determine the maximum value, and the third will determine the minimum value. For example, suppose your program is passed the integers
    1. 90 81 78 95 79 72 85

The program will report

The average value is 82

The minimum value is 72

The maximum value is 95

The variables representing the average, minimum, and maximum values will be stored globally. The worker thread will set these values, and the parent thread will output the values once the workers have exited. (30 points)

  1. How many processes are created in the following program (5 points)

external device. Show the program execution (using format of Figure 1.4) for

  1. Explain the following (20 points)
    1. Difference between short-term and long-term scheduling
    2. Ordinarily the exec() system call follows the fork(). Explain what would happen if a programmer were to inadvertently place the call to exec() before the call to fork().
    3. Difference between parallelism and concurrency
    4. Difference between process and thread
    5. Thread pool and its use

0 34 15 Opcode Address (a) Instruction format 15 0 1 S Magnitude (b) Integer format Program counter (PC) = Address of instruction Instruction register (IR) = Instruction being executed Accumulator (AC) = Temporary storage (c) Internal CPU registers 0001 = Load AC from memory 0010 = Store AC to memory 0101 = Add to AC from memory (d) Partial list of opcodes Figure 1.3 Characteristics of a Hypothetical Machine Fetch stage Execute stage Memory CPU registers Memory CPU registers 3001 940 30 OPC 300 1940 30 PC 3015 941 AC 3015941 000 3 AC 3022 9 41 1 94 0 IR 3022 9 41 1 9 4 0 IR 940 0 0 0 3 941 0 0 0 2 Step 1 Memory 3001 940 3015 941 3022 9 4 1 940 0 0 0 3 941 0 0 0 2 Step 2 CPU registers Memory 30 1PC 300 1940 0003 AC 301 5 941 5 9 4 1 IR 302 2 9 4 1 CPU registers 30 2PC 000S AC 5 9 4 1 IR 3+2 = 5- 9400.0.0.3 9410 0 0 2 Step 3 Memory 300 1 9 40 3015941 3022 9 4 1 9400.003 941 0 0 0 2 Step 4 CPU registers Memory 3.0 2PC 300 1 9 40 0 0 0 5 AC 301 5 941 2.94 1 IR 3022 9 41 CPU registers 30 3 PC 000 SACI 2 9 4 1 IR 9400 OO 3 9410002 9400 OO 3 94110005 Step 5 Step 6 Figure 1.4 Example of Program Execution (contents of memory and registers in hexadecimal) Process A Process B Process C . Dispatcher 0 5 10 15 20 25 30 35 40 45 50 =Ruing = Ready = Blocked Figure 3.7 Process States for Trace of Figure 3.4 int main() { int i; for(i=0;i

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 Databases Questions!