| Instructor - Robert Hochberg Office- STC C-121 Phone- 328-9685 Email- hochberg@cs.ecu.edu |
Text - Operating Systems by
Tannenbaum, second edition. |
The Syllabus can be found here |
We saw four algorithms for
placing processes into holes in memory:
best fit, worst fit, next fit and first fit. Your job is to write
a simulator which will take processes of varying sizes, load them into
memory according to each of those rules, and swap processes out as
needed
to create a larger hole. Let us make the following assumptions:
You can use whatever data structure you wish (eg. linked list, bitmap) to simulate memory usage, but please make sure that the comments in the file clearly indicate what data structure you are using and how it is implemented. Each
time a process is requested to be in memory, print a line
such
as: #proc is the
number
of processes in memory When the last process has been killed, which will also be the
first time since the start that memory becomes empty, summary stats
should be printed: |
Sample
Input File
ff A 30 B 20 C 75 A 30 D 80 C 75 A 30 D 80 A 30 C 75 B 20 A 30 C 75 B 20 E 55 B 20 kill B E 55 D 80 A 30 kill A E 55 kill E D 80 C 75 D 80 C 75 kill C D 80 kill D Sample
Run
|
|
Notes
The first line in the file will be either ff, wf, bf nf or ma (see below) For extra credit, design your own algorithm, including alternatives to LRU, if you wish, and see if you can consistently beat any or all of the four algorithms. The better your algorithm does, the more extra credit, up to 10 points, you will get. That's what the "ma" means up above. To make it easier on me, if you elect not to implement your own algorithm for the extra credit, then please have your program print a message such as "Not implemented," and then gracefully exit, whenever a file starting with "ma" is encountered. |
| Assignment 3, Due November 22, 2007 There is no group work on this third assignment. Each person must write and submit his or her own program. Your assignment is to write a program which will make two Assignment 1-type games play against each other. Requirements:
Assumptions:
Helpful Links and Files: |
Sample Transcript $ comp smart2-5-10 smart2-5-7 1 1 Playing on a 5x5 board smart2-5-10 moved to a1 12345 +-----+ a|X | b| | c| | d| | e| | +-----+ smart2-5-7 moved to c3 12345 +-----+ a|X | b| | c| O | d| | e| | +-----+ smart2-5-10 moved to b3 12345 +-----+ a|X | b| X | c| O | d| | e| | +-----+ smart2-5-7 moved to c2 12345 +-----+ a|X | b| X | c| OO | d| | e| | +-----+ smart2-5-10 moved to c4 12345 +-----+ a|X | b| X | c| OOX | d| | e| | +-----+ smart2-5-7 moved to c1 12345 +-----+ a|X | b| X | c|OOOX | d| | e| | +-----+ smart2-5-10 moved to b4 12345 +-----+ a|X | b| XX | c|OOOX | d| | e| | +-----+ smart2-5-7 moved to b2 12345 +-----+ a|X | b| OXX | c|OOOX | d| | e| | +-----+ smart2-5-10 moved to a2 12345 +-----+ a|XX | b| OXX | c|OOOX | d| | e| | +-----+ smart2-5-7 moved to a3 12345 +-----+ a|XXO | b| OXX | c|OOOX | d| | e| | +-----+ smart2-5-10 moved to b5 12345 +-----+ a|XXO | b| OXXX| c|OOOX | d| | e| | +-----+ smart2-5-7 moved to d2 12345 +-----+ a|XXO | b| OXXX| c|OOOX | d| O | e| | +-----+ smart2-5-10 moved to d4 12345 +-----+ a|XXO | b| OXXX| c|OOOX | d| O X | e| | +-----+ smart2-5-7 moved to e3 12345 +-----+ a|XXO | b| OXXX| c|OOOX | d| O X | e| O | +-----+ smart2-5-10 moved to d3 12345 +-----+ a|XXO | b| OXXX| c|OOOX | d| OXX | e| O | +-----+ smart2-5-7 moved to a4 12345 +-----+ a|XXOO | b| OXXX| c|OOOX | d| OXX | e| O | +-----+ smart2-5-10 moved to a5 12345 +-----+ a|XXOOX| b| OXXX| c|OOOX | d| OXX | e| O | +-----+ smart2-5-7 moved to e2 12345 +-----+ a|XXOOX| b| OXXX| c|OOOX | d| OXX | e| OO | +-----+ smart2-5-10 moved to c5 12345 +-----+ a|XXOOX| b| OXXX| c|OOOXX| d| OXX | e| OO | +-----+ smart2-5-7 moved to d1 12345 +-----+ a|XXOOX| b| OXXX| c|OOOXX| d|OOXX | e| OO | +-----+ smart2-5-10 moved to d5 12345 +-----+ a|XXOOX| b| OXXX| c|OOOXX| d|OOXXX| e| OO | +-----+ smart2-5-7 moved to e4 12345 +-----+ a|XXOOX| b| OXXX| c|OOOXX| d|OOXXX| e| OOO | +-----+ smart2-5-10 moved to b1 12345 +-----+ a|XXOOX| b|XOXXX| c|OOOXX| d|OOXXX| e| OOO | +-----+ smart2-5-7 moved to e1 12345 +-----+ a|XXOOX| b|XOXXX| c|OOOXX| d|OOXXX| e|OOOO | +-----+ smart2-5-10 moved to e5 12345 +-----+ a|XXOOX| b|XOXXX| c|OOOXX| d|OOXXX| e|OOOOX| +-----+ smart2-5-10 (X) had 6 points and smart2-5-7 (O) had 6 points. *** DRAW *** |
| Assignment
4, Due December 10, 2007, before the final. There is no group work on this third assignment. Each person must write and submit his or her own program. Your job is to write the UNIX "pwd" command using inode information. How UNIX pwd works: Hints for your implementation:
|
Notes: When files are stored across a network, you may need to take into account the device id. This is because on separate disks you may find the same inode number, even though the files are different. Here is a sample program to gather the stat information: stat.cpp Here is the one that does not make us of an intermediate file descriptor. stat2.cpp Also note that if "../" points to the parent directory, then "../../" will point to the parent of the parent. Question: I'm not seeing what you mean by using the devic ID, I'm not finding anything to match with. As you said my program finds the path up until the last two correctly. My path isAnswer: When you search a directory for the correct file, compare both the inode number and the device id number. So, for example, I have a line such as if(dotstat.st_ino == buf.st_ino && dotstat.st_dev == buf.st_dev) ... |