Here is the assignment:

1. Objective
This assignment will introduce you to CPU scheduling.

2. Specifications
You are to simulate the execution of processes by a computer system with a large memory, one terminal per user, a CPU, and one disk drive. Each process will be described by it's class (REAL-TIME or INTERACTIVE) and its start time followed by a sequence of resource requests.
These resource requests will include CPU requests (CPU), disk reads (DISK0 and terminal accesses (TTY). In addition, all real-time processes will have a DEADLINE, by which they must complete.
Your input will be a sequence of pairs as in (the ones I included at the start)
All time will be expressed in milliseconds.
Your program should maintain separate ready queues for real-time and interactive processes and give absolute priority to real-time processes over interactive processes:
a) Your scheduler should never allocate the CPU to an interactive process as long as there are one or more real-time processes in the ready state.
b) When a real-time process returns to the ready queue and finds that the CPU is currently allocated to an interactive process, the scheduler should take the CPU away from the interactive process and give it to the real-time process. The pre-empted process should return to the end of the ready queue for interactive processes. When this is the case your program should update the duration of the CPU request by subtracting from the orginal duration te time the process has already spent in the running state.

Disk scheduling will be strictly FCFS without any distinction of process classes.
To simplify your life, we will assume that there is enough memory space for all processes, context switch times can be neglected, user think times are included in the terminal access times, and each process reads and writes to a different terminal.
Your program should read its input file name through input redirection as in:
./a.out < input.txt
If by accident, two resources allocations need to be made at the same time, you should allocate the CPU first then the disk then the terminals.
Your program should have on process table with one entry per process containing a process sequence number, the process class, its process arival time and its current statues (READY,RUNNING,WAITING).
It should print out one line of output every time a process starts or terminates. This line should include the process sequence number, its class and the current simulated time in milliseconds.
When all processes in your input stream have completed, your simulator should print a summary report listing:
a) The number of real-time processes that have completed.
b) The percentage of real-time processes that missed their deadline.
c) The number of interactive processes that have completed.
d) The total number of disk accesses.
e) The average duration of a disk access (including the waiting time in the disk queue).
f) The total time elapsed since the start of the first process.
g) The CPU and DISK utilizations, that is, the fraction of time the CPU or the DISK was busy.

So my first instinct was to use a data structure of a queue to implement the FCFS or FIFO scheduling method. From then on, I'm not sure how to implement this. Anybody have any ideas? Thanks for your help in advance. I will greatly appreciate the help.

Recommended Answers

All 4 Replies

Well, if I understand it correctly, what you mean by FCFS is First Come, First Served, which is really (with some caveats) FIFO, depending upon the length of time required to process the request. Anyway, this is a good exercise for an operating systems class in engineering school. So, assume unlimited memory (no swapping) as per the instructions. Real-time means deterministic. IE, you can determine if a task can be completed in a known time frame. Interactive (non-real-time) processes will be dependent upon available resources, of which the real-time processes have priority.

So, much of this depends upon what you specify are specific performance criteria, such as average (best/worst case) disc access times, time slice allocated per process at runtime, and an entire host of other things. This is a modelling exercise. You need to define ALL limits, constraints, and other hardware and software characteristics before you even get started. FWIW, I hope this is not a freshman class! :-)

That's a very detailed specification that tells you pretty much everything you need to know. This shouldn't be too hard if you just start and then work incrementally through the spec implementing what it says. Start with the "process table" and a couple of queues (use the standard classes from the Java API). code one small piece of functionality at a time and test as you go.

I was thinking on implementing the queue class myself since I took a data structures class. I'm not sure how to you the standard java API classes. I see plenty of them like AbstractQueue, ArrayBlockingQueue, and PriorityQueue classes. So, I'm thinking of creating a queue class, real-time process class, and an interactive process class, and of course a driver class to run the program. I'm not sure which functions I need in these classes. The assignment is very vague in my opinion. Any ideas to get me started on the real-time class or interactive classes? Also, I never used the "input redirection" at all and I need to use it specifically for java. I believe the code

./a.out < input.txt

is the input code for INTERACTIVE 12000, CPU 100, etc... Processed by the classes, then gives a meaningful output after every process ends and a new process begins. This is a senior level operating systems class and I have alright programming ability. My focus is Hardware/VLSI design, so operating systems is kind of out of my scope. Thanks for the help. I appreciate the time spent to read and reply to this post :)

You need to just get started with this. The assignment is more than detailed enough - just do exactly what it says. Once you start coding the questions will become clear and you'll be able to find the answers. If you get stuck, post your code and question here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.