Professional Documents
Culture Documents
Exp 9
1:-
#include<stdio.h>
main()
{
int n,j,temp,temp1,temp2,pr[10],b[10],t[10],w[10],p[10],i;
float att=0;awt=0;
for(i=0;i<10;i++)
{
b[i]=0;w[i]=0;
}
printf(Enter the number of process:);
scanf(%d,&n);
printf(\n Enter the burst time);
for(i=0;i<n;i++)
{
scanf(%d,&b[i]);
p[i]=i;
}
for(i=0;i<n;i++)
{
for(j=1;j<n;j++)
{
if(b[i]>b[j]
{
temp=b[i];
temp1=p[i];
b[i]=b[j];
p[i]=p[j];
b[j]=temp;
p[j]=temp1;
}
}
w[0]=0;
for(i=0;i<n;i++)
w[i+1]=w[i]+b[i];
for(i=0;i<n;i++)
{
t[i]=w[i]+b[i];
awt=aw+w[i]:
att=att+t[i];
}
awt=awt/n;
att=att/n;
printf(\n\t Process \tWaitimgtime \t Turnaroundtime\n);
for(i=0;i<n;i++)
printf(\t p[%d] \t %d\t\t %d\n,p[i].w[i],t[i]);
printf(\n The average waiting time is %t \n,awt);
printf(The average turnaround time is %f\n,att);
return 1;
}
2:-\
3:- Advantages:
6:-
(1) System variables - Created and maintained by Linux itself. This type of variable
(2) User defined variables (UDV) - Created and maintained by user. This type of
You can see system variables by giving command like $ set, some of the important
Graphical user interface provided the much needed thrust for controlling a
computer and its applications. This form of language simplified repetitive
actions. Support for different applications mostly depends upon the
operating system. These interact with menus, buttons, etc.
Read
more: http://softwaretutorial.freeforums.net/thread/185#ixzz4ty41dTlm
9:- 17. List the system calls used for process management:
System calls Description
fork() To create a new process
exec() To execute a new program in a process
wait() To wait until a created process completes its execution
exit() To exit from a process execution
getpid() To get a process identifier of the current process
getppid() To get parent process identifier
nice() To bias the existing priority of a process
brk() To increase/decrease the data segment size of a process
10:-
The cmp command called as compare is used to compare two files byte by
byte and displays the first match.
The diff command called as difference is used to know the changes to be
made to the files to make them identical.
Exp 10
8.0
Medium-term Scheduling
Short-term Scheduling
1:- #include<stdio.h>
#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
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];
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();
}
4:-
Scheduling Criteria
There are many different criterias to check when considering the "best"
scheduling algorithm :
CPU utilization
To make out the best use of CPU and not to waste any CPU cycle,
CPU would be working most of the time(Ideally 100% of the time).
Considering a real system, CPU usage should range from 40%
(lightly loaded) to 90% (heavily loaded.)
Throughput
Turnaround time
Waiting time
The sum of the periods spent waiting in the ready queue amount of
time a process has been waiting in the ready queue to acquire get
control on the CPU.
Load average
Response time
Amount of time it takes from when a request was submitted until the
first response is produced. Remember, it is the time till the first
response and not the completion of process execution(final
response).
6and 8:-
Response time: The time of submission to the time the first response is produced.\
9:-Priority Scheduling
Priority scheduling
Each process in the system if given a priority, then the scheduling must be
done according to the priority of each process. A higher priority job should
get CPU whereas lower priority job can be made to wait. Priority scheduling
is necessarily a form of preemptive scheduling where priority is the basic of
preemption.
Example:
Let us consider a set of processes P1, P2, P3 having priorities ranging from
1 to 3. Let us assume that 1 is the highest priority whereas 3 is the least
priority. Let us also assume that p1 arrive first and P3 arrives in the last.
p1 10 3 0
p2 5 2 1
p3 2 1 2
priority scheduling
The main question arise here is if two processes have been assigned same
priorities. Priority may be assigned by user or by the operating system
depending upon the important of process. In that case comparison will be
done with their CPU burst time. The process with short CPU burst time will
be executed first.
Exp no 11
1.Simplicity.
2.A priority scheduling can leave some low priority waiting processes
indefinitely for CPU.
3.If the system eventually crashes then all unfinished low priority
processes gets lost.
7:- memory, also called CPU memory, is random access memory (RAM)
that a computer microprocessor can access more quickly than it can
access regular RAM. This memory is typically integrated directly with
the CPU chip or placed on a separate chip that has a separate bus
interconnect with the CPU.
9:-
10:-
BASIS
scheduling is cost associated. Non-preemptive scheduling is not cost
associative.
Exp 12
7:-
advantages of RR.
Disadvantages>
8:-
9:-
Mutual Exclusion
No Preemption
Circular Wait
10:-
One-shot Algorithm
Given a request from process P for resources R1, R2, ..., Rn, the
resource manager follows these rules:
else
end if
end if
Silberschatz and Galvin, section 7.4.2: ``One protocol ... requires each
process to request and be allocated all its resources before it begins
execution'' (p.214)
Simple Example:
Person P1 needs knife and fork and person P2 needs knife and fork.
Person P1 requests knife and fork, person P2 also requests knife and
fork.
Only one of P1 or P2 will be granted the resources. Suppose it is P1. P2
is forced to wait.
Since the resources that P2 was waiting for are free, P2 is granted both
the knife and fork
Implementation
Given a request from process P for resources R1, R2, ..., Rn, the
resource manager follows a similar rule to that for one-shot.
else if any resource R1, ... Rn, does not exist, then
else
end if
end if
Hierarchical Algorithm
Assume the resources have unique priorities (i.e., all priorities are
different). Given a request from process P for resource R, the resource
manager follows these rules:
else
end if
Simple Example:
Knife is given priority 2 and fork priority 1, assuming that zero is the
highest priority.
Person P1 needs knife and fork and person P2 needs knife and fork.
Person P1 requests knife first because it is lower priority and then fork.
Since person P2 is waiting for the knife, the request can now be
granted.