SOLVED:CMPSC122 Homework I Soln

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout Second Badge

Description

5/5 - (2 votes)

The overall project for this semester is to simulate process scheduling within an Operating System. At any time, there may be any number of programs that wish to use the machine, but only one can be granted the CPU at a time. Later assignments will address the process scheduling algorithms. This assignment will work on the presentation of the results. The goal is to produce a simple Ascii-graphic representation of the various process states as time progresses. Here is an example representative of what may appear later in the term. Time: 1000 1500 1 DDDDDDDDDDDDDDDDDDD——XXXXNNNNNNNNNN-XXXXX 2 ——————-DDDDDDDDDDDDDDDDDDXXXNNNNN D = Disk N = Network X = Execute (CPU) – = waiting This diagram shows just a small snapshot of the overall simulation between time indices 1000 and 1500. It shows that Process #2 has been wanting to access the Disk, and has to wait until Process #1 is done with it. After a decent period of Disk activity, it is able to proceed with its program (executing), at which point it wishes to access the Network. Fortunately, it does not have to wait for that, since Process #1 finished with the network not long before. On the other hand, when process #1 got its data from the network, it had to wait its turn for access the the CPU. The purpose of the first assignment is not to perform the simulation, but to summarize the results in graphical form like that above. The actual representation of the data will actually use classes and objects, which will be presented later, but for now, the data will be represented in a pair of parallel arrays. For example, the data that went into the diagram for process #2 consisted of this information (along with much data outside the 1000-1500 range): State: – D X N Time: 1000 1220 1420 1460 This indicates that the process began using the disk at 1220, the CPU at 1420, and the network at 1460. SPECIFICATION DETAILS The task for this assignment is to implement a function that will display one row of the diagram above. It will be given the complete history of a process with two parallel arrays (one containing characters such as ‘X’ and ‘0’) and one containing numeric values representing time. The number of array elements will not be provided, but the data will always be terminated by the symbol ‘Q’ among the characters. The ‘Q’ will not appear in the output — it is merely an indicator that the data is finished, and does not represent any activity. The function will also be provided two time indices indicating the beginning and end times of interest (such as 1000 and 1500) in the example. It is to limit its display to within that time range. It is possible that the start time may be earlier than the smallest time stamp in the data, or for the ending time to be after the largest time stamp. In those cases, the output should display space characters — non-space data should be restricted to the range of the simulation itself. Also, this function must be scaleable, so a caller could effectively ‘zoom in’ or ‘zoom out’ of the data. It must occupy between 20 and 50 character positions on the display, for any two endpoint times. For example, the above diagram used 45 characters to show each row, but if the total requested time was 1000, the above data might squeeze down into 23 characters out of 45. NOTE: This ‘zoom’ behavior is to be determined exclusively from the parameters in the parameter list. There is to be no keyboard input anywhere in this program. The wide variety of values between 20 to 50 is to allow some coding flexibility to work around possible rounding during divisions. EXTRA CREDIT OPTION Sometimes a process may use very little CPU time, less than the amount of time represented by a single character of your display. Try to assure that this interesting bit of data is not squeezed out of existence. This feature only applies to the ‘X’ character, and not to any others. The score for this option will be evaluated based on simplicity and clarity as well as correctness. Also be sure to notify the grader of your intent for credit in the Message Box on ANGEL. COMPONENT FILES Header Files (.h) provide declarations to be used by other parts of a large project. Generally these header files also have Source files (.cpp) that provide the implementation for functions whose prototypes appear in the header file. After this assignment, header files will also declare classes, to allow for calling the methods within those classes. This assignment’s header, however, Only includes a single function declaration. histo.h Declares the history display functions
DO NOT CHANGE histo.cpp Implements the display function
Complete and submit driver.cpp Some code to test the display evaluation
Feel free to edit as desired, but do not submit.
A very different version of this file may be used for grading. The only file to be submit for this assignment is histo.cpp. It is expected to be compatible with the given header files. IMPLEMENTATION HINT Instead of making complex decisions about what to output or when to output, it may be simpler to populate an array of characters that will hold your results and just display the entire array at once. The coutobject can output an array of characters as a single << operation, if there is a null character at the end of the data.

  • CMPSCI-Homework-1.zip