Resource allocation using an optimistic resource manager and the banker’s algorithm of Dijkstra… 1 answer below »
The goal of this lab is to do resource allocation using both an optimistic resource manager and the banker’s algorithm of Dijkstra. The optimistic resource manager is simple: Satisfy a request if possible, if not make the task wait; when a release occurs, try to satisfy pending requests in a FIFO manner. Your program takes one command line argument, the name of the file containing the input. After reading (all) the input, the program performs two simulations: one with the optimistic manager and one with the banker. Output is written to stdout (the screen). Input files are available on NYU Classes, together with the expected output. To help in debugging there are also cycle by cycle results included for a few of the examples in the “detailed” files. You are NOT required to produce these “detailed” outputs; they are for your benefit only. We may test your program on additional input as well. The input begins with two values T, the number of tasks, and R, the number of resource types, followed by R additional values, the number of units present of each resource type. (If you set “arbitrary limits” on say T or R, you must document this in your readme, check that the input satisfies the limits, print an error if it does not, and set the limits high enough so that the required inputs all pass.) Then come multiple inputs, each representing the next activity of a specific task. The possible activities are initiate, request, release, and terminate. Time is measured in fixed units called cycles and, for simplicity, no fractional cycles are used. The manager can process one activity (initiate, request, or release) for each task in one cycle. However, the terminate activity does not require a cycle. To ease the programming, I have specified all activities to have the same format, namely a string followed by four unsigned integers. The initiate activity, which must precede all others for that task, is written initiate task-number delay resource-type initial-claim (The optimistic manager ignores the claim.) If there are R resource types, there are R initiate activities for each task, each requiring one cycle. The delay value is not used for initiate; I include it so that all activities have the same format. The request and release activities are written request task-number delay resource-type number-requested release task-number delay resource-type number-released The delay value represents the number of cycles between the completion of the previous activity for this process and the beginning of the current activity. For example, assume the previous activity was a request and the current activity is a release with a delay of 6. Then, after the request is satisfied, the process is delayed 6 cycles before making the release (presumably the task was computing during these 6 cycles, but that is not relevant to the manager and hence not relevant for the lab). The process retains its resources during the delay. Finally the terminate operation, which does not require a cycle is written terminate task-number delay unused unused The last two values are not used; I include them so that all activities have the same format. Commenting your program You must include enough high-level comments in your program so that a reader (e.g., the grader) who is expert in the programming language you use and knowledgeable about resource management can understand the basic operation of your program. For example, you should make clear when you are checking for safety, when you are checking for deadlock, when you are releasing a previously blocked task, etc. You must also supply comments for your major data structures. Each function/procedure/method you write must have an introductory comment stating what the procedure does and how it does it (at a high level). Note that these required comments will form a (small) portion of the grade for this lab. Input format As in lab 1 (linker) we use free form input. Hence a single activity may span several lines and (parts of) several activities may be on one line. For this lab, I advise you to read all the data before processing. The data for each task occurs in order, but the tasks themselves may be interspersed. Input set 1, on the web and reprinted below, has all of task one followed by all of task two. Input set 8, on the web, represents the same run but the lines for tasks one and two are interleaved.