Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CPU control unit has the following phases of operations: Fetch phase, Decode pha

ID: 3855431 • Letter: C

Question

CPU control unit has the following phases of operations: Fetch phase, Decode phase, and Execute phase. The following pseudo-code demonstrates these three phases. Please add more pseudo-codes to implement the following two functions: a) CPU handles Interrupt to enable Interrupt-driven I/O operations: b) CPU solves race conditions PC = : IR = memory[PC]: haltFlag = CLEAR: while(haltFlag not SET) execute(IR): PC = PC + sizeof(INSTRUCT): IR = memory[PC];//fetch phase /* Please add your pseudo-code in the following */

Explanation / Answer

sudo apt-get install build-essential qemu nasm

mov bx, 1000h

mov ax, [bx]

cmp ax, 50

jge label

...

label:

mov ax, 10

mylabel: db 'Message here', 0

foo: db 0

mov byte al, [foo]

BITS 16

start:

mov ax, 07C0h ; Set up 4K stack space after this bootloader

add ax, 288 ; (4096 + 512) / 16 bytes per paragraph

mov ss, ax

mov sp, 4096

mov ax, 07C0h ; Set data segment to where we're loaded

mov ds, ax

mov si, text_string ; Put string position into SI

call print_string ; Call our string-printing routine

jmp $ ; Jump here - infinite loop!

text_string db 'This is my cool new OS!', 0

print_string: ; Routine: output string in SI to screen

mov ah, 0Eh ; int 10h 'print char' function

.repeat:

lodsb ; Get character from string

cmp al, 0

je .done ; If char is zero, end of string

int 10h ; Otherwise, print it

jmp .repeat

.done:

ret

times 510-($-$$) db 0 ; Pad remainder of boot sector with 0s

dw 0xAA55 ; The standard PC boot signature

OR

#include<stdio.h>

int main()

{

int n,bt[20],wt[20],tat[20],avwt=0,avtat=0,i,j;

printf("Enter total number of processes(maximum 20):");

scanf("%d",&n);

printf(" Enter Process Burst Time ");

for(i=0;i<n;i++)

{

printf("P[%d]:",i+1);

scanf("%d",&bt[i]);

}

wt[0]=0; //waiting time for first process is 0

//calculating waiting time

for(i=1;i<n;i++)

{

wt[i]=0;

for(j=0;j<i;j++)

wt[i]+=bt[j];

}

printf(" Process Burst Time Waiting Time Turnaround Time");

//calculating turnaround time

for(i=0;i<n;i++)

{

tat[i]=bt[i]+wt[i];

avwt+=wt[i];

avtat+=tat[i];

printf(" P[%d] %d %d %d",i+1,bt[i],wt[i],tat[i]);

}

avwt/=i;

avtat/=i;

printf(" Average Waiting Time:%d",avwt);

printf(" Average Turnaround Time:%d",avtat);

return 0;

}

C++ Program

#include<iostream>

using namespace std;

int main()

{

int n,bt[20],wt[20],tat[20],avwt=0,avtat=0,i,j;

cout<<"Enter total number of processes(maximum 20):";

cin>>n;

cout<<" Enter Process Burst Time ";

for(i=0;i<n;i++)

{

cout<<"P["<<i+1<<"]:";

cin>>bt[i];

}

wt[0]=0; //waiting time for first process is 0

//calculating waiting time

for(i=1;i<n;i++)

{

wt[i]=0;

for(j=0;j<i;j++)

wt[i]+=bt[j];

}

cout<<" Process Burst Time Waiting Time Turnaround Time";

//calculating turnaround time

for(i=0;i<n;i++)

{

tat[i]=bt[i]+wt[i];

avwt+=wt[i];

avtat+=tat[i];

cout<<" P["<<i+1<<"]"<<" "<<bt[i]<<" "<<wt[i]<<" "<<tat[i];

}

avwt/=i;

avtat/=i;

cout<<" Average Waiting Time:"<<avwt;

cout<<" Average Turnaround Time:"<<avtat;

return 0;

}

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

#include<iostream>

using namespace std;

int main()

{

int n,bt[20],wt[20],tat[20],avwt=0,avtat=0,i,j;

cout<<"Enter total number of processes(maximum 20):";

cin>>n;

cout<<" Enter Process Burst Time ";

for(i=0;i<n;i++)

{

cout<<"P["<<i+1<<"]:";

cin>>bt[i];

}

wt[0]=0; //waiting time for first process is 0

//calculating waiting time

for(i=1;i<n;i++)

{

wt[i]=0;

for(j=0;j<i;j++)

wt[i]+=bt[j];

}

cout<<" Process Burst Time Waiting Time Turnaround Time";

//calculating turnaround time

for(i=0;i<n;i++)

{

tat[i]=bt[i]+wt[i];

avwt+=wt[i];

avtat+=tat[i];

cout<<" P["<<i+1<<"]"<<" "<<bt[i]<<" "<<wt[i]<<" "<<tat[i];

}

avwt/=i;

avtat/=i;

cout<<" Average Waiting Time:"<<avwt;

cout<<" Average Turnaround Time:"<<avtat;

return 0;

}

OR This code in C# :

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ConsoleApplication13

{

class Program

{

static void Main(string[] args)

{

int i, j;

int[] burstTime = new int[5];

int[] waitTime = new int[5];

int[] turnaroundTime = new int[5];

int noOfProcess;

float avgWaitTime = 0;

float avgTurnAroundTime = 0;

Console.WriteLine(“Enter Total Process “);

noOfProcess = Convert.ToInt32(Console.ReadLine());

Console.WriteLine(” Enter Process burst time “);

for ( i=0; i<noOfProcess; i++)

{

burstTime[i] = Convert.ToInt32(Console.ReadLine());

}

Console.WriteLine(" Process Burst Time in Sequence ");

for ( i = 0; i < noOfProcess; i++)

{

Console.WriteLine("P["+i+"]"+"="+burstTime[i]);

}

waitTime[0] = 0;

for (i=0;i<noOfProcess;i++)

{

waitTime[0] = 0;

for ( j=0;j<i;j++)

{

waitTime[i] += burstTime[j];

}

}

Console.WriteLine("Process"+" "+"Burst Time"+" "+"Waiting Time"+" "+"Turn Around Time");

for ( i=0;i<noOfProcess;i++)

{

turnaroundTime[i] = burstTime[i] + waitTime[i];

avgWaitTime += waitTime[i];

avgTurnAroundTime += turnaroundTime[i];

}

for (i = 0; i < noOfProcess; i++)

{

Console.WriteLine("P[" + i + "]" + " " + burstTime[i] + " " +" "+ waitTime[i] + " " + turnaroundTime[i]);

}

avgWaitTime /= i;

avgTurnAroundTime /= i;

Console.WriteLine("Average Waiting Time is :"+avgWaitTime);

Console.WriteLine("Average TurnaroundTime is:"+avgTurnAroundTime);

Console.ReadKey();

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote