Sie sind auf Seite 1von 2

Csci 41 Intro.

to Data Structures Project 1: C++ Reviews and Ch 1


Instructor: Shih-Hsi Alex Liu shliu@csufresno.edu http://zimmer.csufresno.edu/~shliu
Assigned: Feb. 10, 2012 Due: March 2, 2012 (BEFORE CLASS) Directions: You must upload a single zip file (e.g., Liu-Proj1.zip) to blackboard. The file should contain the following: a. All *.cpp and *h files b. Output/result c. For each function or algorithm of your source code, you are requested to explain/comment the concepts/philosophy/theories of the function/algorithm. IF YOU DONT HAVE DETAILED ENOUGH EXPLINATION FOR EACH FUNCTION/ALGORITHM YOU WILL GET 10 PTS OFF). Please DO NOT submit the entire Visual Studio projects to me (DO NOT SUBMIT EXE FILE TO ME). Honor Statement: By turning in your assignment to me, you confirm that all of the work is your own. That is, you did not take your answer and adapt it from someone else, or get detailed advice from another student on how they answered a question. You also cannot give away your answers to another student. You agree, by sending me the answers via email, that this is your own work. This also includes trying to find an answer on the web (if such answers exist, I will find all of them and make sure that your answer is unique). Penalties for cheating and plagiarism range from a 0 or an F on a particular assignment, through an F for the course, to expulsion from the university. In this project, you are to simulate scheduling of operating systems. Scheduling is the method by which threads, processes or data flows are given access to system resources (e.g. processor time, communications bandwidth). Namely, when a processor (we only consider uni-process in this course) is available, scheduling may follow a specific algorithm to dispatch processes/threads to the processor. Several basic algorithms include: First-In-First-Out, Shortest-Remaining-Time, and Round-Robin. In this project, you are to implement First-In-First-Out algorithm. There are several important steps. 1. Read the process execution information from a text file, where the format of each row is: Process_ID, Starting_Time, Execution_Time

1 20 5 2 22 4 3 23 2 4 30 3 2. Dispatch the processes using First-In-First-Out algorithm. A possible partial scenario of executing the algorithm using the above data should look as follows (A stands for arrival, D stands for Departure). Note the purpose of Queue is to perform FIFO and the purpose of List is to sort and log processes based on time: Time 0 20 Action Read file, place process in the List Update the List and Queue: 1. Process 1 enters the queue 2. Process 1 begins execution, create departure log in the list 3. Read file, place process in the list Update the List and Queue: 1. Process 2 enters the queue 2. Read file, place process in the list Update the List and Queue: 1. Process 3 enters the queue 2. Read file, place process in the list Update the List and Queue: 1. Process 1 departs the queue 2. Process 2 begins execution Queue empty [(20,5)] [(20,5)] [(20,5)] [(20,5),(22,4)] [(20,5),(22,4)] [(20,5),(22,4), (23,2)] [(20,5),(22,4), (23,2)] [(22,4), (23,2)] [(22,4), (23,2)] List [(A,20,5)] Empty [(D, 25)] [(A,22,4),(D,25)] [(D,25)] [(A,23,2),(D,25)] [(D,25)] [(D,25),(A,30,3)] [(A,30,3)] [(D,29),(A,30,3)]

22

23

25

continue continue

Requirements: 1. YOU ARE NOT ALLOWED TO USE ANY STANDARD TEMPLATE LIBRARY (STL) EXCEPT VECTOR. Namely, you need to construct queue and list from Node.h. Failure to follow this requirement will result in ZERO point. 2. Possible files needed: Event.h, Node.h, List.h, Queue.h, Simulation.h, Driver.cpp 3. After simulation, print out all the logs (which process enters or departs the process at what time, similar to the above table) 4. Compute the waiting time of each process and print the result at the end of Driver file (Definition: Waiting time: The period of time waiting in the queue before the process is executed. For example, the waiting time for Process 2 is 3 second (2522) and the waiting time for Process 3 is 6 (29-23)).

Das könnte Ihnen auch gefallen