You are on page 1of 17

4:-Yank copies the selected text into a buffer and holds it

until another yank or deletion occurs

9:- Cut and paste:

Position the cursor where you want to begin cutting.

Press v to select characters, or uppercase V to select whole


lines, or Ctrl-v to select rectangular blocks (use Ctrl-q if
Ctrl-v is mapped to paste).

Move the cursor to the end of what you want to cut.

Press d to cut (or y to copy).

Move to where you would like to paste.

Press P to paste before the cursor, or p to paste after.

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:-\

A shell script is a text file that contains a sequence of commands for


a UNIX-based operating system. It's called a shell script because it
combines into a "script" in a single file a sequence of commands that
would otherwise have to be presented to the system from a keyboard
one at a time.

3:- Advantages:

1. To automate the frequently performed operations


2. To run sequence of commands as a single command
3. Easy to use
4. Portable (It can be executed in any Unix-like operating
systems without any modifications)
4:- Disadvantages:

1. Slow execution speed compared to any programming


languages
2. A new process launched for almost every shell command
executed
5:- Major disadvantage of using shell scripting is slow execution of the
scripts. This is because for every command a new process needs to be
started. This slow down can be resolved by using pipeline and filter
commands. A complex script takes much longer time than a normal script.

6:-

In Linux (Shell), there are two types of variable:

(1) System variables - Created and maintained by Linux itself. This type of variable

defined in CAPITAL LETTERS.

(2) User defined variables (UDV) - Created and maintained by user. This type of

variable defined in lower letters.

You can see system variables by giving command like $ set, some of the important

System variables are:

System Variable Meaning


BASH=/bin/bash Our shell name

BASH_VERSION=1.14.7(1) Our shell version name

COLUMNS=80 No. of columns for our screen

HOME=/home/vivek Our home directory

LINES=25 No. of columns for our screen


LOGNAME=students students Our logging name
OSTYPE=Linux Our Os type
PATH=/usr/bin:/sbin:/bin:/usr/sbin Our path settings
PS1=[\u@\h \W]\$ Our prompt settings
PWD=/home/students/Common Our current working directory
SHELL=/bin/bash Our shell name
USERNAME=vivek User name who is currently login to this PC
7:-

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

8:- exit (command) exit is a command used in many operating


system command line shells and scripting languages.
The command causes the shell or program to terminate. ... Typically
an optional exit code can be specified, which is typically a simple
integer value that is then returned to the parent process.

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

1:- Long-term Scheduling

Medium-term Scheduling

Short-term Scheduling

2;- In preemptive mode, currently running process may be interrupted


and moved to the ready State by the operating system.
When a new process arrives or when an interrupt occurs, preemptive
policies may incur greater overhead than non-preemptive version but
preemptive version may provide better service.

It is desirable to maximize CPU utilization and throughput, and to


minimize turnaround time, waiting time and response time.

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

It is the total number of processes completed per unit time or rather


say total amount of work done in a unit of time. This may range from
10/second to 1/hour depending on the specific processes.

Turnaround time

It is the amount of time taken to execute a particular process, i.e. The


interval from time of submission of the process to the time of
completion of the process(Wall clock 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

It is the average number of processes residing in the ready queue


waiting for their turn to get into the CPU.

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:-

Throughput: Number of processes completed per unit time.


Turnaround time: The interval from time of submission of the process to the time of
completion of the process.
Waiting time: The sum of the periods spent waiting in the ready queue.

Response time: The time of submission to the time the first response is produced.\

7:-Organizational memory (OM) (sometimes called institutional or


corporate memory) is the accumulated body of data, information, and
knowledge created in the course of an
individual organization's existence. ... Organizational memory
can only be applied if it can be accessed.

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.

process CPU Burst Time Priority Arrival

p1 10 3 0

p2 5 2 1

p3 2 1 2

The Gantt chart is shown below:

priority scheduling

Waiting time foe P1= o+ (8-1) =7


Waiting time for P2= 1+ (4-2) =3

Waiting time for P3 = 2

Average Waiting Time = (7+3+2) / 3 = 4 Millisecond

Here, the preemption is based on the priority when P1 execute, P2 arrive


with priority 2, which is higher than priority 3 of P1, and thus P1 is
preempted. Similarly when P2 execute, P3 arrive with Priority 1 which is
the highest priority and thus P2 is preempted and soon.

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

3:-Advantages of Priority Scheduling-

1.Simplicity.

2.Reasonable support for priority.

3.Suitable for applications with varying time and resource


requirements.

Disadvantages of Priority Scheduling-

1.Indefinite blocking or starvation.

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.

5:-Memory segmentation is the division of a computer's primary


memory into segments or sections. In a computer system using
segmentation, a reference to a memory location includes a value that
identifies a segment and an offset (memory location) within that
segment.
6:-Paging is a memory management scheme that eliminates the need
for contiguous allocation of physical memory. This scheme permits the
physical address space of a process to be non contiguous.

Logical Address or Virtual Address (represented in bits): An address


generated by the CPU

Logical Address Space or Virtual Address Space( represented in words


or bytes): The set of all logical addresses generated by a program

Physical Address (represented in bits): An address actually available on


memory unit

Physical Address Space (represented in words or bytes): The set of all


physical addresses corresponding to the logical addresses

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.

8:-Fragmentation occurs in a dynamic memory allocation system when


many of the free blocks are too small to satisfy any request.

External Fragmentation: External Fragmentation happens when a


dynamic memory allocation algorithm allocates some memory and a
small piece is left over that cannot be effectively used. If too much
external fragmentation occurs, the amount of usable memory is
drastically reduced. Total memory space exists to satisfy a request, but
it is not contiguous.
Internal Fragmentation: Internal fragmentation is the space wasted
inside of allocated memory blocks because of restriction on the
allowed sizes of allocated blocks. Allocated memory may be slightly
larger than requested memory; this size difference is memory internal
to a partition, but not being used

9:-

Starvation, in general, means a situation where some process has been


denied service for a long time or has been repeatedly denied service.

Starvation in deadlocks: Suppose a set of processes are 1,2,3,n are in


a deadlock at time T1. Now, in order to resolve the deadlock, we may
decide to preempt the process with the lowest priority (Lets say,
process 1) to release all the resources that it is currently holding. This
technique, called resource preemption, should resolve the deadlock.
So, process 1 has been denied service at time T1. Lets say process 1
reenters the system at a later time T2. Now, lets assume that a set of
processes that includes process 1 again get into a deadlock. Now, again
process 1 will be preempted because of its lowest priority. If
preemption of process 1 keeps happening repeatedly, thus not
allowing process 1 to receive service, then we say that process 1 is
experiencing starvation.

Starvation in scheduling: If the scheduling algorithm is priority


scheduling where the processes are serviced in the order of their
priorities, then the lower priority processes will experience starvation
due to the presence of higher priority processes. A technique called
aging, where priorities of processes are increased with time so that
processes that have been waiting for a long time also get service can
be used to counteract starvation. Starvation is also seen in Shortest
Job First scheduling algorithm. Here,the processes with longer burst
times will experience starvation.

10:-

BASIS
scheduling is cost associated. Non-preemptive scheduling is not cost
associative.

Exp 12

7:-

advantages of RR.

1. There is fairness since every process gets equal share of CPU.

2. The newly created process is added to end of ready queue.

3. A round-robin scheduler generally employs time-sharing, giving each


job a time slot or quantum.

Disadvantages>

1. There is Larger waiting time and Response time.

2. There is Low throughput.


3. There is Context Switches.

8:-

A deadlock is a situation in which two computer programs sharing the


same resource are effectively preventing each other from accessing
the resource, resulting in both programs ceasing to function. The
earliest computer operating systems ran only one program at a time.

9:-

How to avoid Deadlocks

Deadlocks can be avoided by avoiding at least one of the four


conditions, because all this four conditions are required
simultaneously to cause deadlock.

Mutual Exclusion

Resources shared such as read-only files do not lead to deadlocks but


resources, such as printers and tape drives, requires exclusive access
by a single process.

Hold and Wait

In this condition processes must be prevented from holding one or


more resources while simultaneously waiting for one or more others.

No Preemption

Preemption of process resource allocations can avoid the condition of


deadlocks, where ever possible.

Circular Wait

Circular wait can be avoided if we number all resources, and require


that processes request resources only in strictly increasing(or
decreasing) order.

10:-

Deadlock Prevention Algorithms


Note: the textbook does not name these algorithms and has very short
descriptions of them. I use a description adapted from R. A. Finkel, An
Operating Systems Vade Mecum, Prentice-Hall, 1988.

One-shot Algorithm

Given a request from process P for resources R1, R2, ..., Rn, the
resource manager follows these rules:

if process P has ever acquired any resources before, then

refuse the request

else if any resource R1, ... Rn does not exist then

refuse the request

else

if any resource R1, ... Rn is not free, then

wait until all resources R1, ... Rn are free

end if

grant process P exclusive access to resources R1, ... Rn

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:

Suppose that a person needs both a knife and fork to eat.

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.

Person P1 uses the knife and fork until finished.

Person P1 releases the knife and fork.

Since the resources that P2 was waiting for are free, P2 is granted both
the knife and fork

Person P2 uses the knife and fork until finished.

Person Ps releases the knife and fork.

Implementation

To implement using semaphores, the system must provide a means of


waiting on multiple resources at the same time.

Wait succeeds if all resources are granted

Otherwise, process must continue waiting

Example: Windows 2000 WaitForMultipleObjects system call

Repeated One-shot (Multishot) Algorithm

Given a request from process P for resources R1, R2, ..., Rn, the
resource manager follows a similar rule to that for one-shot.

if process P currently has any resources, then

refuse the request

else if any resource R1, ... Rn, does not exist, then

refuse the request

else

if any resource R1, ... Rn is not free, then

wait until all resources R1, ... Rn are free

end if

grant process P exclusive access to resources R1, ... Rn


}

end if

If a process P wants to request resources while holding resources, they


follow these steps:

P frees all resources being held

P requests all resources previously held plus the new resources it


wants to acquire

Silberschatz and Galvin, section 7.4.2: ``An alternative protocol allows


a process to request resources only when the process has none. A
process may request some resources and use them. Before it can
request any additional resources, however, it must release all the
resources that it is currently allocated.'' (p.215)

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:

if process P currently has any resources with equal or higher priority

than resources R, then

refuse the request

else if resource R1 does not exist, then

refuse the request

else

if the resource R is not free, then

wait until resource R is free


end if

grant process P exclusive access to resources R

end if

Simple Example:

Suppose that a person needs both a knife and fork to eat.

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.

Person P2 also requests knife and then fork.

Only one of P1 or P2 will be granted the knife. Suppose it is P1.

Person P2 will wait for the knife to be free.

Then only P1 will request the fork.

The request will be granted.

Person P1 will use the knife and fork until finished.

Person P1 will release the knife and fork.

Since person P2 is waiting for the knife, the request can now be
granted.

Then Person P2 will immediately request the fork

You might also like