You are on page 1of 27

AIM: To write a program to implement Producer –Consumer problem using shared

memory.

PROGRAM DESCRIPTION:

Shared Memory - is an efficeint means of passing data between programs. One program will
create a memory portion which other processes (if permitted) can access.A process creates a
shared memory segment using shmget(),The original owner of a shared memory segment can
assign ownership to another user with shmctl(). It can also revoke this assignment. Other
processes with proper permission can perform various control functions on the shared memory
segment using shmctl(). Once created, a shared segment can be attached to a process
address space using shmat(). It can be detached using shmdt() The attaching process must have
the appropriate permissions for shmat(). Once attached, the process can read or write to the
segment, as allowed by the permission requested in the attach operation. A shared segment can
be attached multiple times by the same process. A shared memory segment is described by a
control structure with a unique ID that points to an area of physical memory. The identifier of
the segment is called the shmid. The structure definition for the shared memory segment
control structures and prototype can be found in <sys/shm.h>

One shmid data structure for each shared memory segment in the system. */

struct shmid_ds {
struct ipc_perm shm_perm; /* operation perms */
int shm_segsz; /* size of segment (bytes) */ time_t
shm_atime; /* last attach time */
time_t shm_dtime; /* last detach time */ time_t
shm_ctime; /* last change time */ unsigned short
shm_cpid; /* pid of creator */ unsigned short
shm_lpid; /* pid of last operator */ short
shm_nattch; /* no. of current attaches */ ` }

shmget () - allocates a System V shared memory


segment Syntax:
#include <sys/ipc.h>
#include <sys/shm.h>
int shmget(key_t key, size_t size, int shmflg);

PROGRAME CODE :
#include<stdio.h>
#include<sys/types.h>
#include<sys/shm.h>
#include<sys/sem.h>
#include<sys/ipc.h>
static int pid,semid,shmid,cntid;
char *ptr,*ctr;
struct sembuf sop;
main()
{
int i;
semid=semget((key_t)10,1,IPC_CREAT|0666);
shmid=shmget((key_t)11,100,IPC_CREAT|0666);
cntid=shmget((key_t)12,2,IPC_CREAT|0666);
semctl(semid,0,SETVAL,1);
ptr=(char*)shmat(shmid,0,0);
ctr=(char*)shmat(cntid,0,0); ctr[i];
pid=fork();
if(pid==0)
{
printf("producer starts \n");
producer();

printf("\n producer ends \n");


}
else
{
printf("\n consumer starts");
consumer();
printf("\n consumer ends");
}
}
code1()
{
sop.sem_num=0;
sop.sem_op=-1;
sop.sem_flg=0;
}
code2()
{
sop.sem_num=0;
sop.sem_op=1;
sop.sem_flg=0;
}
producer()
{
int i=0;
for(i=0;i<5;i++)
{
code1();
semop(semid,&sop,1);
printf("\n producing %d",i);
ptr[i]=i;
ctr[i]++;
code2();
semop(semid,&sop,1);
sleep(4);
}
}
consumer()
{
int i,j=0,var=0;
for(i=0;i<5;i++)
{
code1();
semop(semid,&sop,1);
j=ctr[i];
if(j<=0)
{
code2();
semop(semid,&sop,1);
printf("buffer empty");
sleep(4);
}
else

{
var=ptr[i];
j--;
printf("\n consumer %d",var);
code2();
semop(semid,&sop,1);

sleep(4);
}
}
}
OUTPUT:
[sudha@linuxserver semaphores]$ ./a.out
producer starts
consumer starts
producing 0
consuming 0
producing 1
consuming 1
producing 2
consuming 2
producing 3
consuming 3
producing 4
producer ends
consuming 4
consumer ends
EXPERIMENT 11: Readers – Writers problem using message passing.

AIM: To write a program to implement Readers-Writers problem problem using message


passing.

PROGRAME CODE :
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <string.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <pthread.h>
#define SIZE 1024
#define SHMKEY1 (key_t)24
#define SHMKEY2 (key_t)25
#define SEMKEY1 (key_t)26
#define SEMKEY2 (key_t)27
struct databuf
{
int n;
char buf[SIZE];
};
static int wrt, shmidl, readcount, mutex;
struct sembuf sp1,sp2,sv1,sv2;
struct databuf *buff;
char *count;
void writer()

{
semop(wrt,&sp1,1);
printf("\n In the writer process, pid is : %d\n", getpid());
strcpy(buff->buf,"Hello this is writer"); /*strcat(buff-
>buf,(char*)getpid());*/ printf("\n Writer ended");
semop(wrt,&sv1,1);
}
void reader()
{
char str[100];
semop(mutex,&sp2,1);
printf("\n In reader process, pid is : %d\n", getpid());
count[0]+=1;
if(count[0]==1)
{
semop(wrt,&sp1,1);
}
semop(mutex,&sv2,1);
strcpy(str,buff->buf);
printf("\n no. of readers in critical section are %d ", count[0]);
printf("\n read message is %s, my id =%d",str, getpid());
semop(mutex,&sp2,1);
count[0]-=1;
printf("\n no. of readers in critical section are %d", count[0]);
if(count[0]==0)
{
semop(wrt,&sv1,1);
}
semop(mutex,&sv2,1);
}
int i = 0;
void * threadfunctionread(void* param)
{
printf("\nChild Thread with id %u started\n",pthread_self());
++i;
printf("Now threads are: %d\n", i);
reader();
printf("\nChild Thread with id %u ended\n\n",pthread_self());
pthread_exit(0);
}
void * threadfunctionwrite(void* param)
{
printf("\nChild Thread with id %u started\n",pthread_self());
++i;
printf("Now threads are: %d\n", i);
writer();
printf("\nChild Thread with id %u ended\n\n",pthread_self());
pthread_exit(0);
}
main()

{
int p1,p2;
wrt=semget(SEMKEY1,1,IPC_CREAT|0666);
mutex=semget(SEMKEY2,1,IPC_CREAT|0666);
semctl(wrt,0,SETVAL,1);
semctl(mutex,0,SETVAL,1);
shmidl=shmget(SHMKEY1,sizeof(struct databuf),IPC_CREAT|0666);
readcount=shmget(SHMKEY2,2,IPC_CREAT|0666);
count=(char *)shmat(readcount,0,0);
count[0]=0;
buff=(struct databuf*)shmat(shmidl,0,0);
sp1.sem_num=0;
sp1.sem_op=-1;
sp1.sem_flg=0;
sv1.sem_num=0;
sv1.sem_op=1;
sv1.sem_flg=0;
sp2.sem_num=0;
sp2.sem_op=-1;
sp2.sem_flg=0;
sv2.sem_num=0;
sv2.sem_op=1;
sv2.sem_flg=0;
pthread_t t1, t2, t3, t4, t5;
printf("\nMain thread id is %u\n\n",pthread_self());
pthread_create(&t1, NULL, threadfunctionread, NULL);
pthread_create(&t2, NULL, threadfunctionwrite, NULL);
pthread_create(&t3, NULL, threadfunctionread, NULL);
pthread_create(&t4, NULL, threadfunctionread, NULL);
pthread_create(&t5, NULL, threadfunctionread, NULL);
pthread_join(t1, 0);
pthread_join(t2, 0);
pthread_join(t3, 0);
pthread_join(t4, 0);
pthread_join(t5, 0);
semctl( wrt, 0, IPC_RMID, NULL );
semctl( mutex, 0, IPC_RMID, NULL );
shmctl( shmidl, IPC_RMID, NULL );
shmctl( readcount, IPC_RMID, NULL );
printf("\nMain Thread with id %u ended\n",pthread_self());
}
OUTPUT:
[sudha@linuxserver ~]$ cc rewriters.c -pthread
[sudha@linuxserver ~]$ ./a.out
Main thread id is 3086821056
Child Thread with id 3086818192 started
Now threads are: 1
In reader process, pid is : 12307
Child Thread with id 3044858768 started
Now threads are: 2
In reader process, pid is : 12307
no. of readers in critical section are 2
read message is , my id =12307
no. of readers in critical section are 1
Child Thread with id 3044858768 ended
Child Thread with id 3055348624 started
Now threads are: 3
In reader process, pid is : 12307
no. of readers in critical section are 2
read message is , my id =12307
no. of readers in critical section are 1
Child Thread with id 3055348624 ended
Child Thread with id 3076328336 started
Now threads are: 4
Child Thread with id 3065838480 started
Now threads are: 5
In reader process, pid is : 12307
no. of readers in critical section are 2
read message is , my id =12307
no. of readers in critical section are 1
Child Thread with id 3065838480 ended
no. of readers in critical section are 1
read message is , my id =12307
no. of readers in critical section are 0
Child Thread with id 3086818192 ended
In the writer process, pid is : 12307
Writer ended
Child Thread with id 3076328336 ended
Main Thread with id 3086821056 ended
EXPERIMENT 12: Dinning philosopher problem using semaphore

AIM: To write a program to implement Dinning philosopher problem using semaphore

PROGRAM DESCRIPTION:

The program implements Dining philosopher problem which is a circular permutation based
synchronization problem using Semaphores and shared memory.The dining-philosophers
problem is considered a classic synchronization because it is an example of a large class of
concurrency-control problems. It is a simple representation of the need to allocate several
resources among several processes in a deadlock-free and starvation-free manner. Consider
five
philosophers who spend their lives thinking and eating. The philosophers share a circular table
surrounded by five chairs, each belonging to one philosopher. In the center of the table is a
bowl of rice, and the table is laid with five single chopsticks .When a philosopher thinks, she
does not interact with her colleagues. From time to time, a philosopher gets hungry and tries to
pick up the two chopsticks that are closest to her (the chopsticks that are between her and her
left and right neighbors). A philosopher may pick up only one chopstick at a time. Obviously,
she cannot pick up a chopstick that is already in the hand of a neighbor. When a hungry
philosopher has both her chopsticks at the same time, she eats without releasing her chopsticks.
When she is finished eating, she puts down both of her chopsticks and starts thinking again.
One simple solution is to represent each chopstick with a semaphore. A philosopher tries to
grab a chopstick by executing a wait () operation on that semaphore; she releases her
chopsticks by executing the signal() operation on the appropriate semaphores. Thus, the shared
data are semaphore chopstick[5]; where all the elements of chopstick are initialized to 1. Use
an asymmetric solution; that is, an odd philosopher picks up first her left chopstick and then
her right chopstick,
whereas an even philosopher picks up her right chopstick and then her left chopstick
ALGORITHM :

The structure of philosopher i---


do
{
wait (chopstick [i] );
wait(chopstick [(i + 1) % 5] ) ;
.………
// eat
………..
signal(chopstick [i]);
signal(chopstick [(i + 1) % 5]);
// think
} while (TRUE);

PROGRAME CODE :
#include<stdio.h>
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/sem.h>
static int chopstick;
struct sembuf sop;
int main()
{
int p1,p2,p3;
chopstick=semget((key_t)0X25,5,IPC_CREAT|0666);
semctl(chopstick,0,SETVAL,1);
semctl(chopstick,1,SETVAL,1);
semctl(chopstick,2,SETVAL,1);
semctl(chopstick,3,SETVAL,1);
semctl(chopstick,4,SETVAL,1); p1=fork();

p2=fork();
// printf("%d%d",p1,p2);
if(p1==0)
{
if(p2==0)
{
p3=fork();
if(p3==0)
{
sleep(2);
philosopher(2);
}
else
{
sleep(3);
philosopher(3);
}
}
else
{
sleep(1);
philosopher(4);
}
}
else
{
if(p2==0)
{
sleep(2);
philosopher(1);
}
else
{
sleep(4);
philosopher(0);
}
}}
philosopher(int i)
{
while(1)
{
if(i==0||i==2||i==4)
{
printf("\n philosopher %d is thinking",i);
sleep(5);
wait_b(chopstick,i);
wait_b(chopstick,((i+1)%5));
printf("\n philosopher %d has acquired chopsticks",i);
sleep(5);
printf("\n philosopher %d is eating",i);
sleep(5);
signal_b(chopstick,i);
signal_b(chopstick,((i+1)%5));
printf("\n philosopher %d has released or returned the chopstick",i);

sleep(5);
}
else
{
printf("\n philosopher %d is thinking",i);
sleep(5);
wait_b(chopstick,((i+1)%5));
wait_b(chopstick,i);
printf("\nphilosopher %d has acquired both chopstick",i);
sleep(5);
printf("\nphilospher %d is eating");
sleep(5);
signal_b(chopstick,((i+1)%5));
signal_b(chopstick,i);
printf("\n philosopher %d has released chopsticks",i);
sleep(5);
}
}
}
wait_b(int semid,int semnum)
{
sop.sem_num=semnum;
sop.sem_op=-1;
sop.sem_flg=0;
semop(semid,&sop,1);
}

signal_b(int semid,int semnum)


{
sop.sem_num=semnum;
sop.sem_op=1;
sop.sem_flg=0;
semop(semid,&sop,1);
}

OUTPUT:
[sudha@linuxserver ~]$ ./a.out
philosopher 4 is thinking
philosopher 2 is thinking
philosopher 2 has acquired chopsticks
philosopher 2 is eating
philosopher 2 has released or returned the chopstick
philosopher 1 is thinking
philosopher 1 has acquired both chopstick
philospher 1 is eating

philosopher 1 has released chopsticks


philosopher 0 is thinking
philosopher 0 has acquired chopsticks
philosopher 0 is eating
philosopher 0 has released or returned the chopstick
philosopher 4 has acquired chopsticks
philosopher 4 has released or returned the chopstick[sudha@linuxserver ~]$
philosopher 3 is thinking

EXPERIMENT 13: Bankers algorithm for Deadlock detection and avoidance

AIM: To write a program to implement Bankers algorithm for Deadlock detection and
avoidance

PROGRAM DESCRIPTION:

The Banker's algorithm, sometimes referred to as the detection algorithm, is a resource


allocation and deadlock avoidance algorithm developed by Edsger Dijkstra that tests for
safety by simulating the allocation of predetermined maximum possible amounts of
all resources, and then makes an "s-state" check to test for possible deadlock conditions for all
other pending activities, before deciding whether allocation should be allowed to continue.
The algorithm was developed in the design process for the THE operating system and
originally described (in Dutch) in EWD108.[1] When a new process enters a system, it must
declare the maximum number of instances of each resource type that it may ever claim; clearly,
that number may not exceed the total number of resources in the system. Also, when a process
gets all its requested resources it must return them in a finite amount of time.

ALGORITHM:

Step 1: Start the Program

Step 2:Obtain the required data through char and int datatypes.
Step 3:Enter the filename,index block.

Step 4: Print the file name index loop.

Step 5:File is allocated to the unused index blocks

Step 6: This is allocated to the unused linked allocation.

Step 7: Stop the execution

PROGRAM CODE:

#include <stdio.h>

#include <stdlib.h>

intmain()

intMax[10][10], need[10][10], alloc[10][10], avail[10], completed[10], safeSequence[10];

int p, r, i, j, process, count;

count = 0;

printf("Enter the no of processes : ");

scanf("%d", &p);

for(i = 0; i< p; i++)

completed[i] = 0;

printf("\n\nEnter the no of resources : ");

scanf("%d", &r);

printf("\n\nEnter the Max Matrix for each process : ");

for(i = 0; i< p; i++)

printf("\nFor process %d : ", i + 1);

for(j = 0; j < r; j++)


scanf("%d", &Max[i][j]);

printf("\n\nEnter the allocation for each process : ");

for(i = 0; i< p; i++)

printf("\nFor process %d : ",i + 1);

for(j = 0; j < r; j++)

scanf("%d", &alloc[i][j]);

printf("\n\nEnter the Available Resources : ");

for(i = 0; i< r; i++)

scanf("%d", &avail[i]);

for(i = 0; i< p; i++)

for(j = 0; j < r; j++)

need[i][j] = Max[i][j] - alloc[i][j];

do

printf("\n Max matrix:\tAllocation matrix:\n");

for(i = 0; i< p; i++)

for( j = 0; j < r; j++)

printf("%d ", Max[i][j]);

printf("\t\t");

for( j = 0; j < r; j++)

printf("%d ", alloc[i][j]);


printf("\n");

process = -1;

for(i = 0; i< p; i++)

if(completed[i] == 0)//if not completed

process = i ;

for(j = 0; j < r; j++)

if(avail[j] < need[i][j])

process = -1;

break; } } }

if(process != -1)

break;

if(process != -1)

printf("\nProcess %d runs to completion!", process + 1);

safeSequence[count] = process + 1;

count++;

for(j = 0; j < r; j++)

{
avail[j] += alloc[process][j];

alloc[process][j] = 0;

Max[process][j] = 0;

completed[process] = 1;

} } }

while(count != p && process != -1);

if(count == p)

printf("\nThe system is in a safe state!!\n");

printf("Safe Sequence : < ");

for( i = 0; i< p; i++)

printf("%d ", safeSequence[i]);

printf(">\n");

} else

printf("\nThe system is in an unsafe state!!");

OUTPUT
shell scripts.
AIM: To write a program to implement LINUX shell scripts.

15.1. Write a shell program to print the host name and userdefined message.

15.2. Write a shell program to print program to find equal number

15.3. Write a shell program to count number of characters

15.4. . Write a shell program to find the factorial of the number.

15.5. Write a shell program to find whether a given number is even or odd.

15.6. Write a shell program to find the greatest of three numbers.

15.7 . Write a shell program to find file or directory name.

PROGRAM DESCRIPTION:

The shell is the outermost layer of the operating system. Shells incorporate a programming
language to control processes and files, as well as to start and control other programs. The shell
manages the interaction between you and the operating system by prompting you for input,
interpreting that input for the operating system, and then handling any resulting output from
the operating system.

Shells provide a way for you to communicate with the operating system. This communication
is carried out either interactively (input from the keyboard is acted upon immediately) or as a
shell script. A shell script is a sequence of shell and operating system commands that is stored
in a file.

When you log in to the system, the system locates the name of a shell program to execute.
After it is executed, the shell displays a command prompt. This prompt is usually a $ (dollar
sign). When you type a command at the prompt and press the Enter key, the shell evaluates the
command and attempts to carry it out. Depending on your command instructions, the shell
writes the command output to the screen or redirects the output. It then returns the command
prompt and waits for you to type another command.

A command line is the line on which you type. It contains the shell prompt. The basic format
for each line is as follows:

$ Command Argument(s)

The shell considers the first word of a command line (up to the first blank space) as the
command and all subsequent words as arguments.
Note: When libc.a is moved or renamed, the Killed error message is displayed from the shell
because there is no libc.a file available for the system to load and run the utilities. The recsh
command invokes the recovery shell, which provides an ability to rename libc.a if it is
accidently moved.

Shell concepts
Before you start working with the different types of shells available for AIX you need to
understand basic terminology and features.

Korn shell
The Korn shell (ksh command) is backwardly compatible with the Bourne shell (bsh
command) and contains most of the Bourne shell features as well as several of the best
features of the C shell.

Bourne shell
The Bourne shell is an interactive command interpreter and command programming
language.

C shell
The C shell is an interactive command interpreter and a command programming language. It
uses syntax that is similar to the C programming language.

A shell is a piece of software that provides an interface for users of an operating system which
provides access to the services of a kernel. However, the term is also applied very loosely to
applications and may include any software that is "built around" a particular component, such
as web browsers and email clients that are "shells" for HTML rendering engines. The name
shell originates from shells being an outer layer of interface between the user and the internals
of the operating system (the kernel).

PROGRAM CODE

SHELL PROGRAMMING :
1. Write a shell program to print the host name and userdefined message.

CODE :

echo "hi! iam $(hostname)computer!!";

echo "may i know ur name please?"

read n

echo "hi $n"

echo "welcome to my world of $(hostname)computer!!"

echo "goodbye $n"

OUTPUT:

[sudha@linuxserver ~]$ chmod 744 disp.sh

[sudha@linuxserver ~]$ ./disp.sh

hi! iam cc5computer!!

may i know ur name please?

irfan

hi irfan

welcome to my world of cc5computer!!

goodbye irf

2. Write a shell program to print program to find equal number

CODE :

echo "enter n1"

read n1

echo "enter n2"

read n2

if [ "$n1" = "$n2" ]

then
echo "both are equal numbers"

else

echo "both are not equal numbers"

fi

OUTPUT:

[sudha@linuxserver ~]$ chmod 744 equal.sh

[sudha@linuxserver ~]$ ./equal.sh


Run-1:

enter n1

enter n2

both are not equal numbers

Run-2:

[sudha@linuxserver ~]$ ./equal.sh

enter n1 2

enter n2 2

both are equal numbers

3. Write a shell program to count number of characters

CODE :

echo "enter the string"

read str

echo "the number of character in string are"

x= echo "$str"|wc -c

echo "$((x-1))"
OUTPUT:

[sudha@linuxserver ~]$ chmod 744 char.sh

[sudha@linuxserver ~]$ ./char.sh

enter the string

irfan

the number of character in string are

-1

4. Write a shell program to find the factorial of the

number. CODE :

echo "enter a number"

read n

n1=$n

fact=1

while [ $n -ge 1 ]

do

fact=$(($n * $fact))

n=$(($n - 1))

done

echo "$fact"

OUTPUT:

[sudha@linuxserver~]$ chmod 744 fact.sh

[sudha@linuxserver~]$ ./fact.sh

enter a number 6
720

5. Write a shell program to find whether a given number is even or odd.

CODE :

echo "enter a number"

read n1

n2=$(($n1%2))

if [ $n2 -eq 0 ]

then

echo "number is even"

else

echo "number is odd"

fi

OUTPUT:

[sudha@linuxserver~]$ chmod 744 evod.sh

[sudha@linuxserver~]$ ./evod.sh

Run-1:

enter a number 4

number is even

Run-2:

[sudha@linuxserver~]$ ./evod.sh

enter a number 7

number is odd

6. Write a shell program to find the greatest of three numbers.

CODE :

echo "enter n1: "


read n1

echo "enter n2: "

read n2

echo "enter n3: "

read n3

if [ $n1 -gt $n2 -a $n1 -gt $n3 ]

then

echo "$n1 is greatest"

elif [ $n2 -gt $n3 -a $n2 -gt $n1 ]

then

echo "$n2 is greatest"

elif [ $n3 -gt $n1 -a $n3 -gt $n2 ]

then

echo "$n3 is greatest"

else

echo "cant find"

fi

OUTPUT:

[sudha@linuxserver~]$ chmod 744 gtno.sh

[sudha@linuxserver~]$ ./gtno.sh

enter n1: 2

enter n2: 5

enter n3: 4

5 is greatest
7. Write a shell program to find file or directory name.

CODE :

echo "enter a file/directory name: "

read fn

if [ -f $fn ]

then

echo "$fn is a regular file"

elif [ -d $fn ]
then

echo "$fn is a directory"

else

echo "i ve no idea what $fn is"

fi

OUTPUT:

[sudha@linuxserver~]$ chmod 744 file.sh

[sudha@linuxserver~]$ ./file.sh

enter a file/directory name: fork.c

fork.c is a regular file

Viva QUESTIONS

 Define operating system?


 What are the different types of operating systems?
 Define a process?
 What is CPU Scheduling?
 Define arrival time, burst time, waiting time, turnaround time?
 What is the advantage of round robin CPU scheduling algorithm?
 Which CPU scheduling algorithm is for real-time operating system?
 In general, which CPU scheduling algorithm works with highest waiting time?
 Is it possible to use optimal CPU scheduling algorithm in practice?
 What is the real difficulty with the SJF CPU scheduling algorithm?

 What is multi-level queue CPU Scheduling?


 Differentiate between the general CPU scheduling algorithms like FCFS, SJF etc and
multi-level queue CPU Scheduling?
 What are CPU-bound I/O-bound processes?
 What are the parameters to be considered for designing a multilevel feedback queue
scheduler?
 Differentiate multi-level queue and multi-level feedback queue CPU scheduling
algorithms?

 Define file?
 What are the different kinds of files?
 What is the purpose of file allocation strategies?
 Identify ideal scenarios where sequential, indexed and linked file allocation strategies
are most appropriate?
 What are the disadvantages of sequential file allocation strategy?
 What is an index block?
 What is the file allocation strategy used in UNIX?

 What is the purpose of memory management unit?


 Differentiate between logical address and physical address?
 What are the different types of address binding techniques?
 What is the basic idea behind contiguous memory allocation?
 How is dynamic memory allocation useful in multiprogramming operating systems?
 Differentiate between equal sized and unequal sized MFT schemes?
 What is the advantage of MVT memory management scheme over MFT?

 Differentiate between the memory management schemes MFT and MVT?


 What is dynamic memory allocation?
 What is external fragmentation?

 Which of the dynamic contiguous memory allocation strategies suffer with external
fragmentation?
 What are the possible solutions for the problem of external fragmentation?
 What is 50-percent rule?
 What is compaction?
 Which of the memory allocation techniques first-fit, best-fit, worst-fit is efficient?
Why?
 What are the advantages of noncontiguous memory allocation schemes?
 What is the process of mapping a logical address to physical address with respect to
the paging memory management technique?
 Define the terms – base address, offset?

 Differentiate between paging and segmentation memory allocation techniques?


 What is the purpose of page table?
 Whether the paging memory management technique suffers with internal or external
fragmentation problem. Why?
 What is the effect of paging on the overall context-switching time?

 Define directory?
 Describe the general directory structure?
 List the different types of directory structures?
 Which of the directory structures is efficient? Why?
 Which directory structure does not provide user-level isolation and protection?
 What is the advantage of hierarchical directory structure?

 Define resource. Give examples.


 What is deadlock?
 What are the conditions to be satisfied for the deadlock to occur?

 What is disk scheduling?


 List the different disk scheduling algorithms?
 Define the terms – disk seek time, disk access time and rotational latency?

 What is the advantage of C-SCAN algorithm over SCAN algorithm?


 Which disk scheduling algorithm has highest rotational latency? Why?

 Define the concept of virtual memory?


 What is the purpose of page replacement?
 Define the general process of page replacement?
 List out the various page replacement techniques?
 What is page fault?
 Which page replacement algorithm suffers with the problem of Belady’s
anomaly?
 Define the concept of thrashing? What is the scenario that leads to the situation of
thrashing?
 What are the benefits of optimal page replacement algorithm over other page
replacement algorithms?

 Why can’t the optimal page replacement technique be used in practice?

 What is the need for process synchronization?


 Define a semaphore?
 Define producer-consumer problem?

 Discuss the consequences of considering bounded and unbounded buffers in


producer-consumer problem?
 Can producer and consumer processes access the shared memory concurrently? If not
which technique provides such a benefit?

 Differentiate between a monitor, semaphore and a binary semaphore?

 Define clearly the dining-philosophers problem?


 Identify the scenarios in the dining-philosophers problem that leads to the deadlock
situations?

You might also like