0% found this document useful (0 votes)
79 views

SS Lab Outputs Only PDF

The document describes experiments to simulate CPU scheduling algorithms, file organization techniques, and the Banker's algorithm for deadlock avoidance. For the CPU scheduling experiment, it simulates FCFS, SJF, Round Robin, and Priority scheduling and outputs processing times. For file organization, it simulates single level and two level directories as well as a hierarchical structure. For Banker's algorithm, it requests input to set up the resource allocation table and check for safe sequences.

Uploaded by

C G Giridhar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

SS Lab Outputs Only PDF

The document describes experiments to simulate CPU scheduling algorithms, file organization techniques, and the Banker's algorithm for deadlock avoidance. For the CPU scheduling experiment, it simulates FCFS, SJF, Round Robin, and Priority scheduling and outputs processing times. For file organization, it simulates single level and two level directories as well as a hierarchical structure. For Banker's algorithm, it requests input to set up the resource allocation table and check for safe sequences.

Uploaded by

C G Giridhar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

SYSTEM

SOFTWARE
LAB

​C
G Giridhar
CS-5-B
Roll No- 21
1

CONTENTS
1 CPU Scheduling Algorithms 2

2 File Organization 5

3 Banker’s Algorithm 10

4 Disk Scheduling Algorithms 11

5 Producer-Consumer Problem using Semaphores 13

6 Dining Philosophers Problem 14

7 Pass One of Two Pass Assembler 16

8 Pass Two of Two Pass Assembler 17

9 Single Pass Assembler 18

10 Two Pass Macro Processor 19

11 Absolute Loader 21

12 Symbol Table with Hashing 22


2

Experiment 1 :
Simulate the following non-preemptive CPU scheduling algorithms to find turnaround
time and waiting time.
a) FCFS b) SJF c) Round Robin (pre-emptive) d) Priority

Output :

a) FCFS
Enter the number of processes : 5

Enter your choice :


1.FCFS
2.SJF
3.RR
4.Priority 1

Enter the burst time and arrival time


50
Enter the burst time and arrival time
70
Enter the burst time and arrival time
20
Enter the burst time and arrival time
40
Enter the burst time and arrival time
60
SI Bst Arr Turn Wait
1 5 0 5 ms 0 ms
2 7 0 12 ms 5 ms
3 2 0 14 ms 12 ms
4 4 0 18 ms 14 ms
5 6 0 24 ms 18 ms

b) SJF
Enter the number of processes : 5
3

Enter your choice :


1.FCFS
2.SJF
3.RR
4.Priority 2

Enter the burst time and arrival time


20
Enter the burst time and arrival time
50
Enter the burst time and arrival time
30
Enter the burst time and arrival time
60
Enter the burst time and arrival time
10
SI Bst Arr Turn Wait
5 1 0 1 ms 0 ms
1 2 0 3 ms 1 ms
3 3 0 6 ms 3 ms
2 5 0 11 ms 6 ms
4 6 0 17 ms 11 ms

c) RR
Enter the number of processes : 3

Enter your choice :


1.FCFS
2.SJF
3.RR
4.Priority 3

Enter the burst time and arrival time


30
Enter the burst time and arrival time
60
Enter the burst time and arrival time
70
Enter the time slice :2
SI Bst Arr Wait Turn
1 3 0 4 ms 7 ms
2 6 0 7 ms 13 ms
4

3 7 0 9 ms 16 ms

d) Priority Scheduling
Enter the number of processes : 4

Enter your choice :


1.FCFS
2.SJF
3.RR
4.Priority 4

Enter the burst time and arrival time


40
Enter the burst time and arrival time
20
Enter the burst time and arrival time
10
Enter the burst time and arrival time
90
Enter the priority: 2
311
SI Bst Arr Prio Turn Wait
2 4 0 3 4 ms 0 ms
1 2 0 2 6 ms 4 ms
3 1 0 1 7 ms 6 ms
4 9 0 1 16 ms 7 ms
5

Experiment 2:
Simulate the following file organization techniques
a) Single level directory b) Two level directory c) Hierarchical

Output :

a) Single level directory :


Enter name of directory -- A

1. Create File 2. Delete File 3. Search File


4. Display Files 5. Exit
Enter your choice -- 1

Enter the name of the file -- F1

1. Create File 2. Delete File 3. Search File


4. Display Files 5. Exit
Enter your choice -- 1

Enter the name of the file -- F2

1. Create File 2. Delete File 3. Search File


4. Display Files 5. Exit
Enter your choice -- 4

The Files are -- F1 F2

1. Create File 2. Delete File 3. Search File


4. Display Files 5. Exit
Enter your choice -- 3

Enter the name of the file -- F1


File F1 is found
6

1. Create File 2. Delete File 3. Search File


4. Display Files 5. Exit
Enter your choice -- 2

Enter the name of the file -- F2


File F2 is deleted

1. Create File 2. Delete File 3. Search File


4. Display Files 5. Exit
Enter your choice -- 4

The Files are -- F1

1. Create File 2. Delete File 3. Search File


4. Display Files 5. Exit
Enter your choice -- 5

b) Two level directory :


1. Create Directory 2. Create File 3. Delete File
4. Search File 5. Display 6. Exit Enter your choice -- 1

Enter name of directory -- D1


Directory created

1. Create Directory 2. Create File 3. Delete File


4. Search File 5. Display 6. Exit Enter your choice -- 1

Enter name of directory -- D2


Directory created

1. Create Directory 2. Create File 3. Delete File


4. Search File 5. Display 6. Exit Enter your choice -- 5

Directory Files
D1
D2

1. Create Directory 2. Create File 3. Delete File


4. Search File 5. Display 6. Exit Enter your choice -- 2

Enter name of the directory -- D1


Enter name of the file -- F1
File created
7

1. Create Directory 2. Create File 3. Delete File


4. Search File 5. Display 6. Exit Enter your choice -- 5

Directory Files
D1 F1
D2

1. Create Directory 2. Create File 3. Delete File


4. Search File 5. Display 6. Exit Enter your choice -- 4

Enter name of the directory -- D1


Enter the name of the file -- F1
File F1 is found

1. Create Directory 2. Create File 3. Delete File


4. Search File 5. Display 6. Exit Enter your choice -- 3

Enter name of the directory -- D1


Enter name of the file -- F1
File F1 is deleted

1. Create Directory 2. Create File 3. Delete File


4. Search File 5. Display 6. Exit Enter your choice -- 4

1. Create Directory 2. Create File 3. Delete File


4. Search File 5. Display 6. Exit Enter your choice -- 5

Directory Files
D1
D2

1. Create Directory 2. Create File 3. Delete File


4. Search File 5. Display 6. Exit Enter your choice -- 6

c) Hierarchical
You are in root directory.
1. show everything in this directory 2. change directory 3. go to parent directory
4. add new file 5. delete file 6. create new directory 7. delete directory 8. exit
6
Enter the Name:
D1
8

You are in root directory.


1. show everything in this directory 2. change directory 3. go to parent directory
4. add new file 5. delete file 6. create new directory 7. delete directory 8. exit
1
*D1*

You are in root directory.


1. show everything in this directory 2. change directory 3. go to parent directory
4. add new file 5. delete file 6. create new directory 7. delete directory 8. exit
2
Enter directory name:
D1

You are in D1 directory.


1. show everything in this directory 2. change directory 3. go to parent directory
4. add new file 5. delete file 6. create new directory 7. delete directory 8. exit
4
Enter the Name:
F1

You are in D1 directory.


1. show everything in this directory 2. change directory 3. go to parent directory
4. add new file 5. delete file 6. create new directory 7. delete directory 8. exit
5
Enter name of file or directory to delete:
F1
Successfully deleted.

You are in D1 directory.


1. show everything in this directory 2. change directory 3. go to parent directory
4. add new file 5. delete file 6. create new directory 7. delete directory 8. exit
3

You are in root directory.


1. show everything in this directory 2. change directory 3. go to parent directory
4. add new file 5. delete file 6. create new directory 7. delete directory 8. exit
1
9

*D1*

You are in root directory.


1. show everything in this directory 2. change directory 3. go to parent directory
4. add new file 5. delete file 6. create new directory 7. delete directory 8. exit
7
Enter name of file or directory to delete:
D1
Successfully deleted.

You are in root directory.


1. show everything in this directory 2. change directory 3. go to parent directory
4. add new file 5. delete file 6. create new directory 7. delete directory 8. exit
1
Empty directory

You are in root directory.


1. show everything in this directory 2. change directory 3. go to parent directory
4. add new file 5. delete file 6. create new directory 7. delete directory 8. exit
8
10

Experiment 3 :
Implement the banker’s algorithm for deadlock avoidance.

Output :

Enter the number of processes and resources : 5 3

Enter the resource allocation table :


---------------------------------------
010
200
302
211
002
Enter the number of resources available of Type 1 : 10
Enter the number of resources available of Type 2 : 5
Enter the number of resources available of Type 3 : 7
Enter the Maximum resource table :
---------------------------------------
753
322
902
222
433
7 4 3
1 2 2
6 0 0
0 1 1
4 3 1
System is in safe state
Order is : P2 - P4 - P5 - P1 - P3 -
11

Experiment 4:
Implement the producer-consumer problem using semaphores.

Output :
Enter the buffer size : 3
Enter your choice :-
1.Produce 2.Consume 3.Exit
Your choice : 1

Produced Item..
Number of produced items : 1
Number of consumed items : 0
Your choice : 1

Produced Item..
Number of produced items : 2
Number of consumed items : 0
Your choice : 2

Consumed Item..
Number of produced items : 2
Number of consumed items : 1
Your choice : 1

Produced Item..
Number of produced items : 3
Number of consumed items : 1
Your choice : 1

Produced Item..
Number of produced items : 4
Number of consumed items : 1
Your choice : 1

Buffer is full!!!!
Number of produced items : 4
Number of consumed items : 1
12

Your choice : 2

Consumed Item..
Number of produced items : 4
Number of consumed items : 2
Your choice : 2

Consumed Item..
Number of produced items : 4
Number of consumed items : 3
Your choice : 2

Consumed Item..
Number of produced items : 4
Number of consumed items : 4
Your choice : 2

Buffer is empty!!!!!
Number of produced items : 4
Number of consumed items : 4
Your choice : 3
13

Experiment 5 :
Write a program to simulate the working of the dining philosopher’s problem.

Output :
Enter the philosopher number(1-5) : 1
Enter the operation needed
1.Start Eating 2.Stop Eating 3.Exit
1
Philosopher 1 is eating!
Enter the philosopher number(1-5) : 4
Enter the operation needed
1.Start Eating 2.Stop Eating 3.Exit
1
Philosopher 4 is eating!
Enter the philosopher number(1-5) : 3
Enter the operation needed
1.Start Eating 2.Stop Eating 3.Exit
1
Philosopher 3 cannot eat
Enter the philosopher number(1-5) : 1
Enter the operation needed
1.Start Eating 2.Stop Eating 3.Exit
2
Philosopher 1 is thinking!
Enter the philosopher number(1-5) : 2
Enter the operation needed
1.Start Eating 2.Stop Eating 3.Exit
1
Philosopher 2 is eating!
Enter the philosopher number(1-5) : 3
Enter the operation needed
1.Start Eating 2.Stop Eating 3.Exit
14

Experiment 6 :
Simulate the following disk scheduling algorithms.
a) FCFS b)SCAN c) C-SCAN

Output :
DISK SCHEDULING
--------------------
Enter the range : 200
Enter the number of disk requests : 5
Enter the head position (< 200): 40
Enter the requests : 10 20 30 50 60

Enter your choice


1.FCFS 2.SCAN 3.C-SCAN 4.Exit
1
No Disk Req
1 40
2 10
3 20
4 30
5 50
6 60
Seek Time : 80 ms

Enter your choice


1.FCFS 2.SCAN 3.C-SCAN 4.Exit
2
No Disk Req
0 30
1 20
2 10
3 0
4 50
5 60
Seek Time : 100 ms

Enter your choice


15

1.FCFS 2.SCAN 3.C-SCAN 4.Exit


3
No Disk Req
0 30
1 20
2 10
4 0
5 199
6 50
Seek Time : 250 ms

Enter your choice


1.FCFS 2.SCAN 3.C-SCAN 4.Exit
4
16

Experiment 7 :
Implement pass one of a two pass assembler.

Output :

Input.txt :
COPY START 1000
- LDA ALPHA
- ADD ONE
- SUB TWO
- STA BETA
ALPHA BYTE C'KLNCE
ONE RESB 2
TWO WORD 5
BETA RESW 1
- END -

Console :
COPY START 1000

1000 - LDA ALPHA


1003 - ADD ONE
1006 - SUB TWO
1009 - STA BETA
1012 ALPHA BYTE C'KLNCE
1017 ONE RESB 2
1019 TWO WORD 5
1022 BETA RESW 1
1025 - END -
Program length = 25
17

Experiment 8:
Implement pass two of a two pass assembler.

Output :

Intermediate.txt :
COPY START 1000

1000 - LDA ALPHA


1003 - ADD ONE
1006 - SUB TWO
1009 - STA BETA
1012 ALPHA BYTE C'KLNCE
1017 ONE RESB 2
1019 TWO WORD 5
1022 BETA RESW 1
1025 - END -
Length.txt :
25

Console :
H^COPY^1000^25
T^001000^001012^011017^051019^231022^7576786769^00005^
E^001000
18

Experiment 9:
Implement a single pass assembler.

Output :

Input.txt :
COPY START 1000
- LDA ALPHA
- STA BETA
ALPHA RESW 1
BETA RESW 1
- END -

Console :
H^COPY^1000^0c
T^001000^0c^000000^230000
T^1001^02^1006
T^1004^02^1009
E^001000%
19

Experiment 10 :
Implement a two pass macro processor.

Output :

Pass 1 :
Input.txt :
EX1 MACRO &A,&B
- LDA &A
- STA &B
- MEND -
SAMPLE START 1000
- EX1 N1,N2
N1 RESW 1
N2 RESW 1
- END -

Deftab.txt :

EX1 &A,&B
LDA &A
STA &B
MEND

Namtab.txt :
EX1

Pass 2 :
Input.txt :
EX1 MACRO &A,&B
- LDA &A
- STA &B
- MEND -
SAMPLE START 1000
- EX1 N1,N2
N1 RESW 1
N2 RESW 1
20

- END -

Output.txt :
SAMPLE START 1000
. EX1 N1,N2
- LDA N1
- STA N2
N1 RESW 1
N2 RESW 1
- END -
21

Experiment 11:
Implement an absolute loader.

Output :

Input.dat :
H COPY 001000 00107A
T 001000 1E 141033 482039 001036 281030 301015 482061 3C1003 00102A
0C1039 00102D
T 00101E 15 0C1036 482061 081033 4C0000 454F46 000003 000000
T 001047 1E 041030 001030 E0205D 30203F D8205D 281030 302057 549039
2C205E 38203F
T 001077 1C 101036 4C0000 000000 001000 041030 E02079 302064 509039
DC2079 2C1036
E 001000

Output.dat/Console :
----------------------------------------------------------------------------------------------
MEMORY ADDRESS CONTENTS
----------------------------------------------------------------------------------------------

1000 14103348 20390010 36281030 30101548


1010 20613C10 0300102A 0C103900 102D0C10
1020 36482061 0810334C 0000454F 46000003
1030 000000xx xxxxxxxx xxxxxxxx xxxxxxxx
1040 xxxxxxxx xxxxxx04 10300010 30E0205D
1050 30203FD8 205D2810 30302057 5490392C
1060 205E3820 3Fxxxxxx xxxxxxxx xxxxxxxx
1070 xxxxxxxx xxxxxx10 10364C00 00000000
1080 00100004 1030E020 79302064 509039DC
1090 20792C10 36
---------------------------------------------------------------------------------------------
22

Experiment 12 :
Implement a symbol table with suitable hashing.

Output :

Symbol Table Menu


1.Create a Symbol Table
2.Search in the Symbol Table
3.Exit
Enter your choice:1

Enter the Address:1024

Enter The Label:ABC

Do you want to Continue(y/n)?y

Enter the Address:2048

Enter The Label:EFG

Do you want to Continue(y/n)?y

Enter the Address:6144

Enter The Label:XYZ

Do you want to Continue(y/n)?n

The Symbol Table


*****************
Hash Values Address Label
0 0
1 1024 ABC
2 2048 EFG
3 0
4 0
23

5 0
6 6144 XYZ
7 0
8 0
9 0
10 0
Symbol Table Menu
1.Create a Symbol Table
2.Search in the Symbol Table
3.Exit
Enter your choice:2

Enter the Label:ABC

The Label --ABC-- is present in the Symbol Table at Address:1024


Symbol Table Menu
1.Create a Symbol Table
2.Search in the Symbol Table
3.Exit
Enter your choice:2

Enter the Label:PQR

The Label is Not Present in the Symbol Table!!


Symbol Table Menu
1.Create a Symbol Table
2.Search in the Symbol Table
3.Exit
Enter your choice:3

You might also like