KEMBAR78
Operating System LAB - BCP204 | PDF | Operating System | Scheduling (Computing)
0% found this document useful (0 votes)
39 views24 pages

Operating System LAB - BCP204

o.s presentation

Uploaded by

Gaurav singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views24 pages

Operating System LAB - BCP204

o.s presentation

Uploaded by

Gaurav singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

SWAMI RAMA HIMALAYAN UNIVESITY HILL CAMPUS

TOLI DUDHARKHAL

PROGRAM NAME: - B.C.A

BATCH: - 2022-25

SESSION: - 2023-24

COURSE NAME: - OPERATING SYSTEM

COURSE CODE: - BCP204

SUBMITTED TO: - SUBMITTED BY: -

MR. SAURABH KUMAR GAURAV

ASSISTANT PROFESSOR REG. NO.:- PG22111301005

C.S DEPARTMENT ENROLL. NO.: - SRHU22000680

1
Table of Contents

Page No.
1. Course details
1.1. Course objective (s) 3
1.2. Pre-requisites 3
1.3. Learning Outcomes 3
1.4. Syllabus & References 4
2. List of Experiments 7

2
COURSE DETAILS

Course Objective(s)
Students will gain the ability to implement the various DOS & UNIX commands as well as various
program in C.

Pre-requisite
Understanding on C programming.

Learning Outcome
At the end of the course student will be able to:

1. Implement DOS commands (DIR, TYPE, CD, MD etc.)


2. Implement various UNIX commands
3. Implementing various scheduling algorithms.
4. Create programs for handling deadlocks.

3
Syllabus & References

UNIT I 8-LECTURES
Introduction: Operating System and Function, Evolution of Operating System, Batch,
Multiprogramming, Time Sharing and Real Time System, Distributed Operating system, System
Protection, System calls & Interrupt Operating System Structure, System Components, Operating
System Services.
UNIT II 11-LECTURES
Concurrent Processes: Process Concept, Process states, PCB, Principle of Concurrency, Producer /
Consumer Problem, Critical Section, Problem, Semaphores, Classical Problems in Concurrency, Inter
Processes Communication, Process Scheduling.
UNIT III 11-LECTURES
CPU Scheduling: Scheduling Concept, Performance Criteria Scheduling Algorithm, Preemptive &
Non-preemptive scheduling algorithms, Multiprocessor Scheduling. Deadlock: System Model,
Deadlock Characterization, Prevention, Avoidance and Detection, Recovery from Deadlock.
UNIT IV 9-LECTURES
Memory Management: Basic Machine, Resident Monitor, Multiprogramming: Fixed Partition,
Variable Partition, Multiple Base Register, Paging, Segmentation, Paged Segmentation, Virtual'
Memory Concept, Demand Paging, Performance, Paged Replaced Algorithms, Thrashing.

UNIT V 6-LECTURES
I/O Management & Disk Scheduling: I/O Devices and The Organization of I/O Function, I/O
Buffering, Disk I/O, Operating System Design Issues. File System: File Concept, File Organization and
Access Mechanism, File Directories, File Sharing.

Text Book:
1. Milenekovie, "Operating System Concept", McGraw Hill, Delhi.
2. Petersons, "Operating Systems", Addision Wesley.
3. Gupta & Chaturvedi, “Operating Systems”, Dhanpat Rai & Co. Publications, Lat. Edition

References Books:
1. Stalling, Willium, "Operating System", Maxwell Macmillan.
2. Linux: The Complete Reference, Richard Peterson, Osborne McGraw-Hill, 6th Edition.

Mode of Evaluation: Quiz/Assignment/ Seminar/Written Examination

Theory Laboratory Theory and


4
laboratory
Components Internal SEE Internal SEE
Marks
Total Marks
Scaled Marks

Relationship between the Course Outcomes (COs) and Program Outcomes (POs)

Mapping between Cos and Pos


Sl. No. Course Outcomes (COs) Mapped
Program
Outcomes
1 Implement DOS commands (DIR, TYPE, CD, MD etc.) 1,3
2 Implement various UNIX commands. 1,2,3
3 Implementing various scheduling algorithms.
Domain Expertise 3,2,5

Professional Ethics

Life-long Learning
Modern tool usage
Individual and

Environment and
Problem analysis

Communication
sustainability
Program Outcome→
team work

Efficacy
Course
Course Name 1 2 3 4 5 6 7 8
Code

3
BCP 204 Operating Systems
3

1=addressed to small extent


2= addressed significantly
3=major part of course

5
Course Lab Outcomes Assessment
The laboratory component strongly contributes towards the program outcome.
Domain Expertise -PO (1). This evaluation method will be used for the evaluation of lab and
program outcomes of this course.
Measure– percent of students scoring at least 75% marks in lab.
Target – 90% of students

6
LIST OF EXPERIMENTS

1. Do the following
i) Use the cat command to create a file.
ii) use the cat command to display the file
iii) use the vi command to correct any errors in the file
iv) use the sort command to sort the file
2. Practice on DOS commands.
i) General purpose commands.
ii) Directory Related Commands.
iii) File related commands.
3. Write a shell script to input two numbers and perform all mathematical operations on them.
4. Write and execute Even/odd numbers in Linux using shell.
5. Write a shell script to print the current month, date and year.
6. Write and execute Armstrong numbers in Linux using shell.
7. Write a shell script to input a number and find whether that number is prime or not.
8. Write a shell script to input a number and then print its table.
9. Implementing FCFS scheduling in C.
10. Implementing SJF scheduling in C.
11. Implementing Round Robin scheduling in C.
12. Implementing Priority scheduling in C.

7
EXPERIMENT DETAILS

Experiment No:1
Title Do the following
i) Use the cat command to create a file.
ii) use the cat command to display the file
iii) use the vi command to correct any errors in the file
iv) use the sort command to sort the file
Source Code

Output

Experiment No:2

8
Title
Practice on DOS commands.
i) General purpose commands.
ii) Directory Related Commands.
iii) File related commands.
Source Code 1. Click on the start button.
2. Open command prompt and type the various commands.
i) cd.. : This command is used to change directory step by step.
ii) cd\ : This command is used to change the current directory to root
directory.
iii) md : This command is used to make new directory.
iv) cd : This command is used to change current directory.
v) date: This command is used to display the system date.
vi) time : This command is used to display the system time.
vii) rd : This command is used to remove directory.
viii) dir : This command is used to display the directory list.
ix) ver : This command is used to display the version of the system.
x) vol : This command is used to display the volume of the system.
xi) copy con : This command is used to create a new file.
xii) copy : This command is used to copy the file.
xiii) type : This command is used to display the contents of the file.
xiv) ren : This command is used to rename a file.
xv) del : This command is used to delete a file.

Output General Purpose Commands

Directory Related Commands

9
File Related Commands

10
Experiment No:3
Title Write a Simple shell script for basic arithmetic and logical calculations.

Source Code

Output

11
Experiment No:4
Title Write and execute Even/odd numbers in Linux using shell.

Source Code

Output

12
Experiment No:5
Title Write a shell script to print the current month, date and year.
Source Code
Output

13
Experiment No:6
Title Write and execute Armstrong numbers in Linux using shell.
Source Code

Output

14
Experiment No: 7
Title Write a shell script to input a number and find whether that number is prime or not.

Source
Code

Output

15
Experiment No:8
Title Write and Print a table of any numbers in Linux using shell.
Source Code

Output

16
Experiment No: 9
Title Implementation of First come first serve scheduling algorithm in C.
Source Code #include<stdio.h>
#include<conio.h>
#include<dos.h>
main(){
int i,j,x,y[50]; float x1,x2,x3; clrscr();
printf("\nEnter the no of process "); scanf("%d",&x);
for(i=1;i<=x;i++) {
printf("\nEnter execution time for %d process ",i); scanf("%d",&y[i]); }
printf("\nThe CPU burst gets in following way\n");
for(i=1;i<=x;i++) { delay(500);
printf("\nThe process P%d executes",i); }
x1=0;y[0]=0; for(i=1;i<=x-1;i++) {
x1=x1+y[i]+y[i-1]; }
x1=x1/x;
printf("\n\nThe average waiting time is [%f]",x1);
x2=0;
for(i=1;i<=x;i++) {
x2=x2+y[i]; } x2=x2/x;
printf("\n\nThe average turn around time is [%f]",x2);
getch(); return 0;}
Output

17
Experiment No:10
Title Implementation of Shortest Job First (SJF) scheduling algorithm in C.
Source Code #include<conio.h>
#include<graphics.h>
void main() {
int i,tp,t[6],ex[6],w[6],ta[6],gd=DETECT,gm,n,j;
float tc,p=0,a=0;
int temp,s2[10]; char s[5],s1[5]; clrscr();
initgraph(&gd,&gm,"c:\\tc\\bgi");
printf("\n Enter the number of processes-->");
scanf("%d",&n); printf("\nEnter burst time for the processes\n");
for(i=1;i<=n;i++)
scanf("%d",&t[i]);
for(i=1;i<=n;i++) {
for(j=i+1;j<=n;j++) {
if(t[i]>t[j]) {
temp=t[i];
t[i]=t[j];
t[j]=temp; } } }
for(i=1;i<=n;i++) {
s2[1]=0;
s2[i+1]=s2[i]+t[i];
p=p+s2[i];
ta[1]=t[1];
ta[i+1]=ta[i]+t[i+1];
a=a+ta[i]; }
printf("\n\tProcess \tWaiting Time \t Turn Around Time\n");
for(i=1; i<=5; i++)
printf("\n\tP%d\t\t%d\t\t%d",i,s2[i],ta[i]);
line(50,100,50+ta[5]*5,100);
line(50,130,50+ta[5]*5,130);
line(50,100,50,130);
outtextxy(50,131,"0");
for(i=1;i<6;i++){
line(50+ta[i]*5,100,50+ta[i]*5,130);
sprintf(s2,"%d",ta[i]);
outtextxy(50+ta[i]*5,131,s2);
sprintf(s1,"P%d",i); tp=50+s2[i]*5;
tc=(50+ta[i]*5-tp)/2.0;
outtextxy(tp+tc,115,s1); }
printf("\n\n\n");
p/=5.0;
a/=5.0;
printf("\nAverage waiting time : \t\t%f\nAverage turnaround time : \t%f\
nThroughput : \t\t\t%d",p,a,ta[5]); getch(); }

18
Output

19
Experiment No:11
Title Implementing Round Robin scheduling in C.
Source Code #include<stdio.h>
#include<conio.h>
int main() {
int count,j,n,time,remain,flag=0,time_quantum;
int wait_time=0,turnaround_time=0,at[10],bt[10],rt[10];
printf("Enter Total Process:\t ");
scanf("%d",&n); remain=n;
for(count=0;count<n;count++) {
printf("Enter Arrival Time and Burst Time for Process Process Number
%d :",count+1);
scanf("%d",&at[count]);
scanf("%d",&bt[count]);
rt[count]=bt[count]; }
printf("Enter Time Quantum:\t");
scanf("%d",&time_quantum);
printf("\n\nProcess\t|Turnaround Time|Waiting Time\n\n");
for(time=0,count=0;remain!=0;) {
if(rt[count]<=time_quantum && rt[count]>0) {
time+=rt[count];
rt[count]=0;
flag=1; }
else if(rt[count]>0) {
rt[count]-=time_quantum;
time+=time_quantum; }
if(rt[count]==0 && flag==1) {
remain--;
printf("P[%d]\t|\t%d\t|\t%d\n",count+1,time-at[count],time-
at[count]-bt[count]);
wait_time+=time-at[count]-bt[count];
20
turnaround_time+=time-at[count];
flag=0; }
if(count==n-1)
count=0;
else if(at[count+1]<=time)
count++;
else
count=0; }
printf("\nAverage Waiting Time= %f\n",wait_time*1.0/n);
printf("Avg Turnaround Time = %f",turnaround_time*1.0/n);
return 0; }
Output

21
Experiment No:12
Title Implementing Priority scheduling in C.

Source Code #include<stdio.h>


#include<conio.h>
void main() {
int x,n,p[10],pp[10],pt[10],w[10],t[10],awt,atat,i;
printf("Enter the number of process : ");
scanf("%d",&n);
printf("\n Enter process : time priorities \n");
for(i=0;i<n;i++) {
printf("\nProcess no %d : ",i+1);
scanf("%d %d",&pt[i],&pp[i]);
p[i]=i+1; }
for(i=0;i<n-1;i++) {
for(int j=i+1;j<n;j++) {
if(pp[i]<pp[j]) {
x=pp[i];
pp[i]=pp[j];
pp[j]=x;
x=pt[i];
pt[i]=pt[j];
pt[j]=x;
x=p[i];
p[i]=p[j];
p[j]=x; } }}
w[0]=0; awt=0;
t[0]=pt[0];
atat=t[0];
for(i=1;i<n;i++) {
w[i]=t[i-1];
awt+=w[i];
t[i]=w[i]+pt[i];

22
atat+=t[i]; }
printf("\n\n Job \t Burst Time \t Wait Time \t Turn Around Time Priority \n");
for(i=0;i<n;i++)
printf("\n %d \t\t %d \t\t %d \t\t %d \t\t %d \n",p[i],pt[i],w[i],t[i],pp[i]);
awt/=n; atat/=n;
printf("\n Average Wait Time : %d \n",awt);
printf("\n Average Turn Around Time : %d \n",atat);
getch();}
Output

23
24

You might also like