Вы находитесь на странице: 1из 3

OS
426/526
Midterm
#1
February
9,
2009


Name:_______________________________________


1. (5)
Describe
an
operating
system
function
that
exists
to
ensure
the
efficient

operation
and
access
to
shared
system
resources.



2. (5)
There
are
three
major
API
interfaces
that
give
access
to
system
functions.


Why
not
access
the
system
functions
directly
though
system
calls?


3. (10)
Give
two
reasons
why
the
one‐to‐one
threading
model
and
the
many‐to‐
one
threading
models
may
not
be
ideal
for
every
situation.




4. (5)
Describe
a
method
of
interprocess
communication.





5. (10)
For
a
multi‐programmed
machine
with
time‐shared
access,
from
which

of
the
following
CPU
scheduling
algorithms
do
you
expect
to
get
the
best
wait

time
in
practice
(not
theoretical
performance)?
FCFS,
SJF,
round‐robin

(quantum
is
small),
round‐robin
(quantum
is
large).

Please
explain
your

reasoning.



6. (10)
How
does
a
microkernel
differ
from
a
regular
kernel?

What
are
the

benefits?


7. (10)
Two
major
differences
between
process
creation
and
thread
creation.




8. (5)
Describe
a
method
for
evaluating
a
CPU
scheduling
algorithm.





9. (5)
Can
a
process
starve
if
non‐preemptive
scheduling
is
used?

Explain.






10. 
(5)Name
two
challenges
for
multi‐core
programmers.




11. 
(10)
What
does
the
following
code
print?

#include <pthread.h>


#include <stdio.h>
#include <stdlib.h>
#define NUM_THREADS 3

void *PrintHello(void *threadid)


{
long taskid = (long)threadid;
printf("Hello from thread %ld\n", taskid);
pthread_exit(NULL);
}

int main(int argc, char *argv[])


{
pthread_t threads[NUM_THREADS];
int rc;
long t;

for(t=0;t<NUM_THREADS;t++) {
printf("Creating thread %ld\n", t);
rc = pthread_create(&threads[t], NULL, PrintHello, (void *) &t);
if (rc) {
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
}
}

12.
(20)
Give
the
Gantt
charts,
turnaround
and
wait
times
for
FCFS,
SJF
(non‐
preemptive),
round
robin
(quantum=3)
and
priority
(preemptive)
for
the

following
CPU
load.

For
round
robin,
assume
arriving
jobs
are
added
at
the
end

of
the
queue.

Process
 Arrival
Time
 Burst
Time



Priority


 
 
P1
 0.0
 10
 
 2



 
 
P2

 2.0
 2
 
 1


 
 
P3
 4.0
 4
 
 4


 
 
P4
 6.0
 3
 
 3


Вам также может понравиться