8 Solved Problems on Computer System Structures - Exam 1 | E C E 329, Exams of Electrical and Electronics Engineering

Material Type: Exam; Class: COMP SYS STRUCT; Subject: ELECTRICAL AND COMPUTER ENGINEERING; University: Clemson University; Term: Spring 2006;

Typology: Exams

Pre 2010

Uploaded on 07/28/2009

koofers-user-5q3
koofers-user-5q3 🇺🇸

10 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 329 Section 01 Spring 2006 Exam 1 Name:__________KEY_________
Grade:______________________
1.) Term matching: Write the BEST term for each definition. Not all terms will be used. Some
may be used twice. (12 points)
batch system process round-robin monitor
multi-programmed sys. PCB shortest remaining time first critical region
time-shared sys. waiting queue aging critical section
hard real-time running queue starvation hold-and-wait
soft real-time ready queue deadlock no preemption
interrupt vector CPU scheduler multilevel queue scheduling circular wait
device status table time quantum queueing-network analysis deadlock prevention
asynchronous IO long-term scheduler simulation deadlock avoidance
synchronous IO short-term scheduler race condition deadlock detection
DMA degree of
multiprogramming multilevel feedback queue
scheduling deadlock recovery
memory-mapped IO process mix mutual exclusion bounded buffer
programmed IO medium-term scheduler bakery algorithm user mode
interrupt-driven IO context switch banker's algorithm supervisor mode
cache thread atomicity main memory
volatile user-level threads fetch and add hard disk drive
non-volatile kernel-level threads semaphore sigsetjmp
microkernel first come first serve spinlock siglongjmp
monolithic kernel shortest job first readers writers setitimer
__semaphore____: A synchronization mechanism that is higher level than hardware-based approaches and
provides a counter for solving a variety of synchronization problems.
__time-shared systems_____: Allows users to interact with their programs by switching among them fast
enough that the response time is usually tolerable.
____race condition____: Causes the outcome to depend on the order in which concurrent accesses take place
and is often associated with non-deterministic behavior.
___asynchronous I/O___: Control is immediately returned to the user program without waiting for completion.
______aging______: Technique is used in conjunction with scheduling algorithm to dynamically adjust process
priority to prevent starvation. (MLFBQ -.5)
_____programmed I/O______: Status must be polled to determine completion. (spinlock -.5)
pf3
pf4
pf5

Partial preview of the text

Download 8 Solved Problems on Computer System Structures - Exam 1 | E C E 329 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

ECE 329 Section 01 Spring 2006 Exam 1 Name :__________KEY_________

Grade :______________________

1.) Term matching: Write the BEST term for each definition. Not all terms will be used. Some

may be used twice. (12 points)

batch system process round-robin monitor multi-programmed sys. PCB shortest remaining time first critical region time-shared sys. waiting queue aging critical section hard real-time running queue starvation hold-and-wait soft real-time ready queue deadlock no preemption interrupt vector CPU scheduler multilevel queue scheduling circular wait device status table time quantum queueing-network analysis deadlock prevention asynchronous IO long-term scheduler simulation deadlock avoidance synchronous IO short-term scheduler race condition deadlock detection DMA degree of multiprogramming multilevel feedback queue scheduling deadlock recovery memory-mapped IO process mix mutual exclusion bounded buffer programmed IO medium-term scheduler bakery algorithm user mode interrupt-driven IO context switch banker's algorithm supervisor mode cache thread atomicity main memory volatile user-level threads fetch and add hard disk drive non-volatile kernel-level threads semaphore sigsetjmp microkernel first come first serve spinlock siglongjmp monolithic kernel shortest job first readers writers setitimer __semaphore____: A synchronization mechanism that is higher level than hardware-based approaches and provides a counter for solving a variety of synchronization problems. __time-shared systems_____: Allows users to interact with their programs by switching among them fast enough that the response time is usually tolerable. ____race condition____: Causes the outcome to depend on the order in which concurrent accesses take place and is often associated with non-deterministic behavior. asynchronous I/O: Control is immediately returned to the user program without waiting for completion. ______aging______: Technique is used in conjunction with scheduling algorithm to dynamically adjust process

priority to prevent starvation. (MLFBQ -.5)

_____programmed I/O______: Status must be polled to determine completion. (spinlock -.5)

2.) True/False: For each statement, indicate whether the statement is true (T) or false (F). If a statement is not necessarily true, then it is false. (15 points) T Processes wait in the ready queue. (processes wait in the ready queue to chosen by the CPU scheduler for access to the processor) F_ The degree of multiprogramming is controlled by the short-term scheduler. (no, MPL is controlled by the long term scheduler) F_ Deadlock-free implies starvation-free T_ Starvation-free implies deadlock-free (because of no processes will ever starve, then there can't be any deadlock) F_ Threads share the code section, global data section, and registers. (threads all have their own copy of the registers that they save as part of their state) F_ In preemptive CPU scheduling, a process is always stopped during its CPU burst and forced to give up the processor to another process. (no, b/c it might finish it's CPU burst before the scheduler forces it to stop for another process) F_ A cycle in the resource allocation graph implies that deadlock has occurred. (no, it is a necessary condition, but not sufficient. It is only sufficient in the case where all resource types only have one instance, therefor this statement is not always true, so it is false) T_ Deadlock avoidance requires a priori knowledge of processes' resource requirements (it needs to know the max resource usages of the process to be able to successfully grant requests that guarantee that no deadlock will occur) F_ Non-preemptive CPU scheduling is used when a process switches from the running state to the ready state. (because the only reason that a process would switch from the running state to the ready state is because it was stopped before it finished it CPU burst, which is what a preemptive scheduler would do) F_ In shortest remaining time first scheduling, the long-term scheduler requires an estimate of each processes next CPU burst in order to determine which process will have the shortest remaining CPU burst time. (everything is true here, except it is the short-term scheduler that it is true for) 3.) Short Answer: Briefly explain the DIFFERENCE between the two terms: (12 points) a) ready queue and wait queue ready queue is where the processes wait for access to the CPU, while the wait queue is where they wait for I/O or some other event to complete. When a process finishes its CPU burst and begins its I/O burst, it is transferred from the ready queue to the wait queue and the CPU scheduler then selects a ready process from the ready queue to run on the CPU. When a process is run. it is moved from the ready queue to the running queue. b) short-term and long-term scheduling The long-term scheduler decides which of the submitted processes to load into memory and place in the ready queue, and therefore, controls the multiprogramming level. The short-term scheduler, otherwise known as the CPU scheduler, selects a job from among the jobs waiting in the ready queue, according the governing CPU scheduling algorithm. c) response time and turnaround time Both are metrics for evaluating the performance of systems. TAT is the total time the process spends in the

system, from time of submission to the time is terminates. The response time is the time from the submission

of a request until the first response is produced.

d) message passing and shared memory Both are ways to share information between cooperating processes. With MP, the receiver (and sometimes the sender) must be named, either implicitly or explicitly. Messages are passed from one process to another, typically via a mail-box, although this does not have to be the case. MP is particularly useful in a distributed environment. With shared memory, the process normally have access to the same global address space, and they agree to share regions of their allotted address space with one another. In this case, the processes can simply load and store data to the same memory locations they have agreed on.

6.) CPU Scheduling: Assume non-preemptive shortest job first scheduling. Fill in the Gantt

chart for the processes in the chart provided (show CPU burst as thick solid bar, IO burst as a

line, and wait time as a wavy line). (You do not HAVE TO fill in the note column) (14 points)

Arrival Time CPU Burst I/O Burst

P1 0 10 20

P2 5 15 10

P3 10 20 5

(Fill in the chart from time 0 to time 90, then answer the three questions below chart)

Time P1 P2 P3 Note

0 R NA NA P1 arrive to empty system, immediately runs

5 R W NA P2 arrives but has to wait due to P

10 IO R W P1 stops, starts IO, P3 arrives, and P2 runs b/c shorter burst

15 IO R W

20 IO R W

25 IO IO R P2 stops, starts IO, P3 runs b/c it is the only one that is ready

30 W IO R P1 finishes IO, it now ready, but has to wait on P

35 W W R P2 finishes IO, is now ready, but has to wait on P

40 W W R

45 R W IO P3 stops, starts IO, and P1 runs because it is shorter than P

50 R W W

55 IO R W P1 stops, starts IO, and P2 runs because it is shorter than P

60 IO R W

65 IO R W

70 IO IO R P2 stops, starts IO, R3 runs because it is the only one ready

75 W IO R

80 W W R P2 finishes, but has to wait on P

85 W W R P1 finishes, but has to wait on P

90 You don't have to do this line, b/c you stop at 90

CPU Utilization = the CPU is never idle, so there the utilization is 100%

Average Wait Time = (WP1 + WP2 + WP3) / 3 = (15+15+5+20+10+15+20)/3 = 33.3 time units

Does starvation occur during the first 90 time units? No, b/c every process gets some access to the

CPU.

7.) Discussion: Write a short paragraph to answer ONE of the following questions: (11 points)

Option 1: What are the trade-offs between user-level and kernel-level threads?

User threads are supported and managed above the kernel and are implemented by a thread library at

the user level. They are managed without help from the kernel. They are generally fast to create and

manage; however if the kernel is not multi-threaded, then if a user-level thread blocks, it causes the

entire process to block, even if other threads in the process are available to run.

Kernel-level threads are supported and managed directly by the kernel and are generally slower to

create and manage. However, if a thread blocks, the kernel can schedule another thread in the

application.

Option 2: What are the trade-offs among deadlock prevention, avoidance, and detection/recovery?

Deadlock prevention is a set of methods for ensuring that at least one of the necessary conditions

cannot hold. These methods prevent deadlock by constraining how requests for resources are made.

This implies that it can be viewed as the most restrictive method to prevent deadlock. It may also lead

to less efficient usage of system resources.

Deadlock avoidance requires that the OS be given in advance additional information concerning which

resources a process will request and use during its lifetime. With this additional knowledge, we can

decide for each request whether or not to current request can be satisfied or must be delayed. This

information may or may not be available a priori, and therefore, while deadlock avoidance WILL

PREVENT deadlock, it requires information that may be hard to obtain, therefore it may be considered

less pragmatic in practice.

If a system does not employ deadlock avoidance or prevention, then a deadlock could occur, and a

deadlock detection algorithm can be used to determine if deadlock has in fact occurred, and if so, which

processes are involved in the deadlock.

If resources types only have one instance, all that you need to do to detect a deadlock is to see if there is

a cycle in the wait-for graph, if so, there is a deadlock, and the processes in the cycle are causing the

deadlock (or you might say that the last one added that completed the cycle is actually causing the

deadlock). With deadlock detection, a wait-for graphs needs to be maintained, and a detection

algorithm should be periodically invoked to determine the presence of deadlocks. Then a recovery

mechanism for breaking out of the deadlock needs to be employed. This might consist of killing one

process at a time until deadlock is broken, or it might involve the preemption of resources thereby

breaking deadlock. Also, a checkpointing / rollback mechanism could be employed, but these last two

recovery strategies may be quite hard to implemetn in practice as preemption of resources might lead to

an inconsistent state, and rollback is costly and potentially complex.

==18497== by 0x804847D: main (code.c:23) ==18497== Address 0x1B92A070 is 0 bytes after a block of size 16 alloc'd ==18497== at 0x1B9042A4: malloc (vg_replace_malloc.c:130) ==18497== by 0x804845D: main (code.c:21) ==18497== ==18497== Invalid read of size 4 ==18497== at 0x8048414: foo (code.c:14) ==18497== by 0x804847D: main (code.c:23) ==18497== Address 0x1B92A070 is 0 bytes after a block of size 16 alloc'd ==18497== at 0x1B9042A4: malloc (vg_replace_malloc.c:130) ==18497== by 0x804845D: main (code.c:21) data[4] = 4 data[0] = 0 data[1] = 1 data[2] = 2 data[3] = 3 ==18497== ==18497== Invalid write of size 4 ==18497== at 0x80483FF: foo (code.c:13) ==18497== by 0x804848C: main (code.c:24) ==18497== Address 0x1B92A0B0 is 0 bytes after a block of size 16 alloc'd ==18497== at 0x1B9042A4: malloc (vg_replace_malloc.c:130) ==18497== by 0x804846C: main (code.c:22) ==18497== ==18497== Invalid read of size 4 ==18497== at 0x8048414: foo (code.c:14) ==18497== by 0x804848C: main (code.c:24) ==18497== Address 0x1B92A0B0 is 0 bytes after a block of size 16 alloc'd ==18497== at 0x1B9042A4: malloc (vg_replace_malloc.c:130) ==18497== by 0x804846C: main (code.c:22) data[4] = 4 ==18497== ==18497== Invalid free() / delete / delete[] ==18497== at 0x1B9047A9: free (vg_replace_malloc.c:152) ==18497== by 0x804849B: main (code.c:25) ==18497== Address 0x52BFE3A8 is on thread 1's stack ==18497== ==18497== ERROR SUMMARY: 5 errors from 5 contexts (suppressed: 13 from 1) ==18497== malloc/free: in use at exit: 32 bytes in 2 blocks. ==18497== malloc/free: 3 allocs, 2 frees, 40 bytes allocated. ==18497== For counts of detected errors, rerun with: -v ==18497== searching for pointers to 2 not-freed blocks. ==18497== checked 49152 bytes. ==18497== ==18497== LEAK SUMMARY: ==18497== definitely lost: 32 bytes in 2 blocks. ==18497== possibly lost: 0 bytes in 0 blocks. ==18497== still reachable: 0 bytes in 0 blocks. ==18497== suppressed: 0 bytes in 0 blocks. ==18497== Use --leak-check=full to see details of leaked memory