Sunteți pe pagina 1din 2

BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI First Semester 2003-2004 Course Title : OPERATING SYSTEMS Course No CS C372

Component : Test I (Regular) Open Book Component Weightage : 15% Max Marks: 15 Date: 27/09/2004
Note: Attempt all the Questions. Start each answer from a fresh page. Question #1 (5 Marks) A multilevel feedback queue algorithm works with the following condition Number of queues 3 + 1 Auxiliary Queue (Q1, Q2 and Q3) Scheduling algorithm Q1 uses Virtual Round Robin, Q2 uses Round Robin Q3 uses Highest Response Ratio Next Method used to upgrade a process No upgrading among queues Method to demote a process Q1 After 6 units of time (Quantum time 6), Q2 After 6 units of time (Quantum time 6)(if preempted in Q2 the process will continue remain in the front of the queue till the quantum time expiry), Q3 Highest Response Ratio process in the queue will get the first chance. Method used to determine which queue a process will enter P1, P3 & P4 are entering through Queue #1 (Q1), P2 is entering through Queue #2 (Q2) Process Total CPU burst CPU burst I/O burst Arrival time P1 32 16 6 0 P2 26 10 4 1 P3 10 3 15 2 P4 32 14 1 5 Calculate Average waiting time, average turn around time, and CPU utilization Question #2 (2 Marks) (a) Briefly explain the major differences between a client communicating with a server via message passing and via remote procedure calls (RPCs). (b) Select those items in the list below that a thread shares with other threads in the same process. (a) Address space (b) Heap (c) Program counter (d) Files (e) Local variables registers (f) Global variables (g) Program code (h) Stack pointer Question #3 Find the number of new processes created. void main() { int i; for(i=0;i<=1;i++) { fork(); if(!fork()) { fork(); execl(/bin/ls,ls,NULL); fork(); } fork(); } fork(); } Question #4 The letters A, B in the following program represents some C statements. #include <stdio.h> void main( int argc, char *argv[] ) { int i,p[2]; for( i=1; i<= argc-2; i++ ) { (3 Marks)

(3 Marks)

Operating Systems (CS C372) Test #1

pipe(p); if ( fork( ) ) { } }

else

The program is to be run with k arguments as ./a.out a1 a2 a3 . ak For each of the following A and B, determine if the program implements one of a1 | a2 | a3 | | ak, ak | . | a3 | a2 | a1, ak | a1, a1 | ak or none of these pipes (a) If A is dup2 ( p[0], fileno ( stdin ) ); close ( p[0] ); close ( p[1] ) ; B is dup2 ( p[1], fileno ( stdout ) ); close ( p[0] ); close ( p[1] ) ; execlp ( argv[i], argv[i], ( char * ) 0 ); The program implements__________________ (b) If A is dup2 ( p[0], fileno ( stdin ) ); close ( p[0] ); close ( p[1] ) ; execlp ( argv[i], argv[i], ( char * ) 0 ); B is dup2 ( p[1], fileno ( stdout ) ); close ( p[0] ); close ( p[1] ) ; The program implements __________________ (c) If A is dup2 ( p[1], fileno ( stdout ) ); close ( p[0] ); close ( p[1] ) ; B is dup2 ( p[0], fileno ( stdin ) ); close ( p[0] ); close ( p[1] ) ; execlp ( argv[i], argv[i], ( char * ) 0 ); The program implements__________________ (d) If A is dup2 ( p[1], fileno ( stdout ) ); close ( p[0] ); close ( p[1] ) ; execlp ( argv[i], argv[i], ( char * ) 0 ); B is dup2 ( p[0], fileno ( stdin ) ); close ( p[0] ); close ( p[1] ) ; The program implements __________________ Question #5 Consider the following program #define _REENTRANT #include <stdio.h> #include <pthread.h> int turn = 10; void * many ( void * arg ) { pthread_t tid; if ( - - turn > 0) { printf( %d\t, turn ); pthread_create ( &tid, NULL, many, ( void * ) 0); pthread_join( tid, NULL ); } } int main( ) { many ( NULL ) ; return 0; (2 Marks)

}
Find all the output sequences (Including duplications if any), if the threads are following FCFS scheduling. pthread_join will push the thread to waiting state.

Operating Systems (CS C372) Test #1

S-ar putea să vă placă și