Computers and Technology
Computers and Technology, 03.12.2019 17:31, tami5

141os is a very simple operating system that allows multiple users to save and print files. the 141os manages multiple disks, multiple printers, and multiple users - all of which can be considered concurrent processes. files can be stored on any disk and printed on any printer by any user. the goal of the system is to exploit possible parallelism to keep the devices (disks and printers) as busy as possible. this will be a two week assignment. the first part (due week 9) is to define the java classes for userthread, disk, and printer. the second part (due week 10) is to write printjobthread that manage printing a specified file and userthread that saves files to disk sectors. (note only one line of a file may be stored in a sector, so a file will require one sector per line.) although printers and disks can be thought of as parallel processes, i suggest you not make them threads. if you do, you must make them daemon threads by calling setdaemon or your program will never terminate.

1. define symbolic constants for number_of_users=4, number_of_disks=2, and number_of_printers=3. store instances of the appropriate objects in three separate arrays: users, printers, and disks.

2. a sample of the input (user*) and output (printer*) is in the hw8 directory located in my homework starts directory *** here ***. the printer* files will be generated by your program, but the exact files that get sent to each printer may vary. if you use a bufferedwriter, be sure you flush the buffer after each write.

hw8

design sketch part i: define class userthread, printer, disk, diskmanager, and directorymanager. only userthread will be derived from class thread. define class directorymanager that maps file names into disk sectors. you may want to define a diskmanager to keep track of the next free sector on each disk and to contain the directorymanager for finding file sectors on disk.

1. stringbuffer: implemented as an array of char, will be the standard unit stored on disks, sent to printers (one line at a time) and handled by users (again, one line at a time).

2. disks. each disk has a capacity specified to the constructor. the constructor must allocate all the stringbuffers (one per sector) when the disk is created and must not allocate any after that.

3. operation include the following:

class disk

{

static final int num_sectors = 1024;

stringbuffer sectors[] = new stringbuffer[num_sectors];
void write(int sector, stringbuffer data);

void read(int sector, stringbuffer data);

}

4. you can only read or write one line at a time, so to store a file, you must issue a write for each input line. you may implement it as an array of stringbuffers. we are using stringbuffers because strings are not modifyable. note also stringbuffer. equals must do a deep equality if you plan to do comparisons. reads and writes each take 200 miliseconds. you must sleep the thread that asks to print or read a sector.

5. note you can have only one user writing to a disk at a time or the files will be jumbled. you can have any number of threads reading at a time - even when someone is writing to the disk. (note this is not normally the case in a real os, i had to simplify the problem somehow.)

6. printer. each printer will write data to a file named printeri where i is the index of this printer. a printer can only handle one line of text at a time. you give it a line and it takes 2750 miliseconds to print. you'll have to sleep your the thread that asks to print to simulate this delay.

7. userthreads. each user will read from a file named useri where i is the index of this user. each useri file will contain a series of the following three commands. anything between a .save and a .end is part of the data in file x. userthreads will handle the command evaluation.
.save x
.end
.print x

8. the userthread will handle saving files to disk, but it will create a new printjobthread to handle each print request.

9. each userthread may have only one local stringbuffer to hold the current line of text. if you read strings from the input file, you must immediately copy that string into this single stringbuffer owned by the userthread. the userthread interprets the command in the stringbuffer or saves the stringbuffer to a disk as appropriate.

10. the directorymanager is a table that knows where files are stored on disk. the directorymanager operations are:

class directorymanager

{

hashtable t = new hashtable();

void enter(stringbuffer key, fileinfo file);

fileinfo lookup(stringbuffer key);

}

11. a fileinfo object will hold the disk number, length of the file (in sectors), and the index of the starting sector

class fileinfo

{

int disknumber;

int startingsector;

int filelength;

}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 05:20, ashcormu11
Write a program called assignment3 (saved in a ïŹle assignment3.java) that computes the greatest common divisor of two given integers. one of the oldest numerical algorithms was described by the greek mathematician, euclid, in 300 b. c. it is a simple but very e↔ective algorithm that computes the greatest common divisor of two given integers. for instance, given integers 24 and 18, the greatest common divisor is 6, because 6 is the largest integer that divides evenly into both 24 and 18. we will denote the greatest common divisor of x and y as gcd(x, y). the algorithm is based on the clever idea that the gcd(x, y) = gcd(x ! y, y) if x > = y and gcd(x, y) = gcd(x, y ! x) if x < y. the algorithm consists of a series of steps (loop iterations) where the “larger” integer is replaced by the di↔erence of the larger and smaller integer. this continues until the two values are equal. that is then the gcd.
Answers: 3
image
Computers and Technology, 23.06.2019 06:00, ashleyd198308
Respond to the following in three to five sentences. select the workplace skill, habit, or attitude described in this chapter that you believe is most important for being a successful employee.
Answers: 1
image
Computers and Technology, 23.06.2019 15:30, Dweath50
The processing of data in a computer involves the interplay between its various hardware components.
Answers: 1
image
Computers and Technology, 23.06.2019 20:00, boo3972
Match the file formats with the types of multimedia they can store
Answers: 2
Do you know the correct answer?
141os is a very simple operating system that allows multiple users to save and print files. the 141o...

Questions in other subjects:

Konu
Mathematics, 08.12.2021 05:40
Konu
Mathematics, 08.12.2021 05:40