辅导VB.NET、辅导VC++、辅导I/O CPU管理、VB编程辅导

- 首页 >> C/C++编程


CAS CS-350: Fundamentals of Computing Systems (Spring 2018)

In this (mostly coding) assignment, you will be simulating a system modeled as a network of queues, in

which multiple types of processes exist, and in which scheduling decisions (which process is given the

resource next) will take into account various considerations. Your job will be to report on the overall

performance of the system as well as the performance of the system as experienced by the different types

of processes. We will get to this point progressively as follows:

1. Develop a discrete event simulator for a system (reproduced from Assignment A3, Problem #2) in

which processes submitted to the system follow the following lifecycle.

(i) The process uses the CPU and then with a probability 0.1 proceeds to step (ii), with probability

0.4 proceeds to step (iii), and with probability 0.5 proceeds to step (iv).

(ii) The process performs a disk I/O and then with a probability 0.5 proceeds to step (i), and with

probability 0.5 proceeds to step (iii).

(iii) The process performs a network I/O and then proceeds to step (i).

(iv) The process is done!

The following information is known about the above system.

- Process arrivals are Poisson with a rate of 40 processes per second.

- The CPU is a dual-core design; the ready queue is serviced by any one of the 2 CPU cores.

- The CPU service time is exponential with mean of 20 msec.

- Disk I/O service time is exponential with mean of 100 msec.

- Network service time is exponential with mean of 25 msec.

- There is plenty of memory, so all buffers are of infinite size.

Run your simulation for 100 seconds and answer the following questions (make sure your simulator

reaches steady state before making the measurements below):

a. Using your simulator, empirically measure the average turnaround time (response time) for

processes submitted to your simulator. Your answer should match (within the bounds of your

confidence interval) the analytical results from Assignment A3, Problem #2.

b. Using your simulator, empirically measure the slowdown of the system. Recall that the slowdown

is the ratio between the typical response time (measured above) and the response time when no

delays are introduced through queuing, which can be approximated by the response time when

the load on the system (the arrival rate) is reduced by (say) an order of magnitude. Your empirical

measurement should more or less match the analytical results from Assignment A3, Problem #3.

c. Using your simulator, empirically measure the capacity of the system. Recall that the capacity is

the maximum load that the system can handle at steady state. Notice that when you simulate a

system at a load that is very close to its capacity, the system will behave rather erratically,

exhibiting high variability. This may require you to observe the system for a very long time to get

measurements with some degree of confidence. Your empirical measurement should more or less

match the analytical results from Assignment A3, Problem #3.

2. You were asked to take a closer look at workload that the system you simulated in Problem #1 is

supposed to support. Upon doing this, you concluded that while the mean arrival rate (40 processes

per second) and mean CPU service time (20 milliseconds) were correct, the assumption about the

service time being exponentially distributed was flawed.

Here is what you found. There are two types of processes in the workload: CPU-bound and I/O-bound.

CPU-bound processes are rare (i.e., they arrive very infrequently) but they are very “hungry” for the

CPU; they have very long CPU bursts between needing to use I/O devices. On the contrary, I/O-bound

processes are frequent but use the CPU for very short bursts between needing to use I/O devices.

• The arrival of CPU-bound processes was found to be Poisson with a rate of 2 processes per second.

Their CPU service time was measured to be exponential with a mean of 248 milliseconds.

• The arrival of I/O-bound processes was found to be Poisson with a rate of 38 processes per

second. Their CPU service time was measured to be exponential with a mean of 8 millisecond.

Since there are two types of processes in the system, you now need to provide separate metrics for

each type of process separately. Modify your simulator to allow empirical measurement of the

response time and slowdown for CPU-bound processes and for I/O-bound processes. To do this you

will need to change the simulator you used in Problem #1 to allow you to keep track of request-specific

metadata, including arrival time, type of process, and any other information or statistics you may want

to keep about the process. Notice that in order to simulate the arrival of two types of processes; you

will need to have two types of arrivals (each with its own rate).

Run your simulation for 100 seconds and answer the following questions (make sure your simulator

reaches steady state before making the measurements below):

a. Using your simulator, empirically measure the average turnaround time (response time) for each

type of processes. Does your answer make sense compared to what you obtained in Problem #1,

part (a)?

b. Using your simulator, empirically measure the slowdown experienced by each type of processes.

Does your answer make sense compared to what you obtained in Problem #1, part (b)? How does

the slowdown for each type of process compare to that of the other type?

c. Using your simulator, empirically measure the average number of processes from each type in

the various queues in the system. Remember to use the PASTA principle!

3. In all simulations, so far, the selection of which request to serve next out of a queue (i.e., a scheduling

strategy) was not specified, and typically taken to be First-Come-First-Serve (FCFS). As discussed in

class (and as you may have found in working on Problems #1 and #2 above), while the mean metrics

across all types of requests may not depend on the scheduler, the relative performance certainly does.

To evaluate empirically the goodness of various scheduler, you will need to modify your simulator to

allow different scheduling strategies to be implemented. Of course, in general, there could be

different scheduling strategies for the various devices, but for purposes of this assignment, you only

need to do this for the CPU queue.

Implement a scheduling strategy that gives priority to I/O-bound jobs. In other words, when a process

is to be selected from amongst a number of processes waiting in the CPU queue, the scheduler will

always pick an I/O-bound process, if any are in the queue. If multiple I/O-bound processes are in the

queue, it picks up the one waiting longest (i.e., FCFS). If no I/O-bound processes are in the queue, it

picks the CPU-bound process waiting the longest.

Run your simulation for 100 seconds and answer the following questions (make sure your simulator

reaches steady state before making the measurements below):

a. Using your simulator, empirically measure the average turnaround time (response time) for each

type of processes. How does your answer compare to what you obtained in Problem #2, part (a)?

b. Using your simulator, empirically measure the slowdown experienced by each type of processes.

How does your answer compare to what you obtained in Problem #2, part (b)?

c. Using your simulator, empirically measure the average number of processes from each type in

the various queues in the system. How does that compare to the results you obtained in Problem

#2, part (c)?

4. [Bonus Problem] In this problem, you will need to modify your simulator to allow the use of preemptive

schedulers that use timeouts for preemption. To do this, you will need to introduce a new

event in the simulator: the timeout event that models the expiration of a CPU quantum. When a

timeout occurs, the process whose quantum expired, need to be put at the back of the queue and

another process is selected using whatever selection criterion is operative (e.g., FCFS or priority

queueing). Notice that the process that is put at the back of the queue should keep track of the

remaining amount of service time it needs from the CPU.

Modify your simulator and repeat Problem #2 using a round-robin scheduler. Using a round-robin

scheduler, upon timeout, the process selected next for service is the one waiting longest.

Run your simulation for 100 seconds and answer the following questions (make sure your simulator

reaches steady state before making the measurements below):

a. Using your simulator, empirically measure the average turnaround time (response time) for each

type of processes. How does your answer compare to what you obtained in Problems #2 and #3,

part (a)?

b. Using your simulator, empirically measure the slowdown experienced by each type of processes.

How does your answer compare to what you obtained in Problem #2 and #3, part (b)?

What to hand in: Please hand in your code for the above, as well as evidence that your code works.

Such evidence could be a log showing the results (including statistics) of executing your code. Also,

provide a short write-up answering the various questions asked above.

Note: We will grade and “run” your code! To be able to do so, you will need to submit your code in

its source format (e.g., a.java) with annotation (at least for the core classes and functions), and a

“README” file explaining the following:

1. how to run your program

2. the dependency of the source code files

3. the functions in each file

Note that the source code will account a portion of the grade. Only submitting the results without

source code will result in hefty penalties.

To be able to run your code and replicate your results, make sure to provide the seeds you use to run

your simulations. You could do this by printing the seed at the beginning of each simulation.


站长地图