OSY Solved Manual
OSY Solved Manual
Ans. When exception is thrown by main() method, Java Runtime terminates the
program and print the exception message and stack trace in system console.
fi The throws clause only states that the method throws a checked
FileNotFoundException and the calling method should catch or rethrow it
if [ -x $line ]
4. How to check permissions of all files and directories?
then
Ans. Check Permissions in Command-Line with Ls Command
echo ―$line has all the execute permissions‖ If you prefer using the command line, you can easily find a file's permission
settings with the ls command, used to list information about files/directories.
fi You can also add the –l option to the command to see the information in the
long list
if [ -w $line ]
5. What are the test commands to check the permissions of a file?
then Ans. The bash shell test command has many more options as follows:
-w FILE : FILE exists and write permission is granted.
echo ―$line has all the write permissions‖ -x FILE : FILE exists and execute (or search) permission is granted.
-d FILE : FILE exists and is a directory.
fi -e FILE : FILE exists.
Output : -f FILE : FILE exists and is a regular file.
EXERCISE :
1) Write a shell script which displays the list of all executable files in the current working
directory
Ans.
pwd
fi Output :
done
Output :
3) Write a shell script which accepts a filename and assign it all the permissions.
2) Write a shell script which displays a list of all the files in the current directory to which Ans.
user has read, write and execute permission.
Echo ―ENTER THE FILE : ‖
Ans.
Read file
pwd
Chmod u+xrw $file
ls > f
Chmod o+xrw $file
exec < f
Chmod g+xrw $file
while read line
Output :
do
if [ -f $line ]
then
then
echo ―$line has all the permissions‖ CONCLUSION : We have successfully performed scripts to check and grant permission to
fi files.
fi
P2 6
P3 3
P4 2 Result/Output :
#include<stdio.h>
#include<conio.h>
int main()
{
int n,bt[20],wt[20],tat[20],avwt=0,avtat=0,i,j;
printf("\nEnter Total Number of Processes(maximum 20):");
scanf("\n%d",&n);
printf("\n enter process burst timen");
for(i=0;i<n;i++)
{
printf("\nP[%d]:",i+1);
scanf("\n%d",&bt[i]);
}
PRACTICAL RELATED QUESTIONS :
wt[0]=0;
for(i=1;i<n;i++) 1. Compare SJF, Priority and RR with respect to turnaround time and average waiting
{ time.
wt[i]=0;
Ans.
for(j=0;j<i;j++)
wt[i]+=bt[j]; SJF RR Priority
}
printf("\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time:"); 1.Turnaround time is 1.turnaround time is 1. Turnaround time
for(i=0;i<n;i++) more than FCFS. more than Priority. is less than RR.
{
2.Average waiting 2.The average waiting 2.In this scheduling
tat[i]=bt[i]+wt[i];
time for given set of time for given set of algorithm the
avwt+=wt[i];
processes is processes is quite small average waiting
avtat+=tat[i];
minimum. and depends on the time time is small as
printf("\nP[%d]\t\t%d\t\t%d\t\t%d",i+1,bt[i],wt[i],tat[i]);
quantum. compare to FCFS.
}
avwt/=i;
avtat/=i;
printf("\n\nAverage Waitng Time: %d",avwt); 2. State the conditions for preemptive and non-preemptive scheduling algorithm.
printf("\nAverageTurnaround Time: %d",avtat); Ans.
return 0;
Conditions for preemptive and non-preemptive scheduling algorithm:-
}
When a process switches from the running state to the waiting state(for example,
I/O request, or invocation of wait for termination of one of the child processes). Process Burst Time
When a process switches from running state to the ready state (for example, when P1 12
an interrupt occurs). P2 45
When a process switches from the waiting state to the ready state (for example, P3 78
completion of I/O). P4 90
When a process terminates.
Ans. The reason behind this is, in time sharing operating system it is necessary that each
user should get CPU share after certain interval. It would be terrific to allow one process 0 12 32 52 72 92 112 132 137 157 177 195 215 225
to keep the CPU for long time. Waiting Time :
P1=0
4. Write a formula for turnaround Time.
P2=12+(72-32)+(132-92)=92
Ans. Turnaround Time= Ending Time - Arrival Time
P3=32+(92-52)+(137-112)+(177-157)=117
5. Write a formula for Average waiting Time. P4=52+(112-72)+(157-132)+(195-177)+(215-215)=135
Ans. Average waiting Time =
Average Waiting Time:
Waiting time of p1+ waiting time of p2+ …+waiting time of pN / No. of processes.
0+92+117+135 ÷4 = 344÷4= 86
EXERCISE :
3. The jobs are scheduled for execution are as follows:
1. Draw the Gantt chart for above mention example. Solve the problem using FCFS and Preemptive SJF find average waiting time using
Gantt chart.
Process Burst Time Process Arrival Time Burst Time
P1 21 P1 0 10
P2 6 P2 1 4
P3 3 P3 2 14
P4 2 P4 3 8
1) FCFS
Gantt chart: Gantt Chart:
P1 P2 P3 P4 P1 P2 P3 P4
0 21 27 30 32
0 10 14 28 36
Waiting time
2. Calculate average waiting time using RR algorithm for following set of processes
with the length of the CPU burst time given in milliseconds. ( Time quantum 20 ms ). P1=0
P2=10-1=9
P3=14-2=12
Gantt chart:
PRACTICAL SIGNIFICANCE :
When there is a page fault, the referenced page must be loaded. If there is no available frame in
P1 P2 P4 P1 P3 memory, then one page is selected for replacement. if the selected page has been modified, it
0 1 5 13 22 36 must be copied back to disk (swapped out). A page replacement algorithm is needed to decide
which page needs to be replaced when a new page comes in.
Waiting Time:
P1=12
MINIMUM THEORETICAL BACKGROUND :
P2=1-1=0
This is the simplest page replacement algorithm.in this algorithm operating system keeps track of
P3=22-2=20 all pages in the memory in a queue, oldest page is in the front of the queue. when a page needs to
be replaced page in the front of the queue is selected for removal.
P4=5-3=2
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
printf("\n ENTER THE NUMBER OF FRAMES :"); return 0;
scanf("%d",&no); getch();
for(i=0;i<no;i++) Result/Output :
frame[i]= -1;
j=0;
for(i=1;i<=n;i++)
printf("%d\t\t",a[i]);
Flag =0;
for(k=0;k<no;k++)
if(frame[k]==a[i])
Flag=1;
if (Flag==0)
frame[j]=a[i];
count++;
for(k=0;k<no;k++)
printf("%d\t",frame[k]);
printf("\n");
Disadvantages of FIFO:-
1. FIFO method is improper if many lots are purchased during the period at different
prices.
2. The objective of matching current costs with current revenues can not be achieved
under FIFO method.
3. If the prices of materials are rising rapidly, the current production cost may be
understated.
4. FIFO method overstates profit especially in inflation.