subject
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;

}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:30
Nathan wants to create multiple worksheet containing common formatting styles for his team members. which file extension him to save these worksheets? nathan to create multiple worksheets with common styles. he needs to save them with the extension.
Answers: 1
question
Computers and Technology, 25.06.2019 05:00
7. the cullerton park district holds a mini-olympics each summer. create a class named participant with fields for a name, age, and street address. include a constructor that assigns parameter values to each field and a tostring() method that returns a string containing all the values. also include an equals() method that determines two participants are equal if they have the same values in all three fields. create an application with two arrays of at least eight participants each—one holds participants in the mini-marathon, and the other holds participants in the diving competition. prompt the user for participant values. after the data values are entered, display values for participants who are in both events. save the files as participant.java and twoeventparticipants.java.
Answers: 2
question
Computers and Technology, 25.06.2019 05:50
Acolor class has three public, integer-returning accessor methods: getred, getgreen, and getblue, and three protected, void-returning mutator methods: setred, setgreen, setblue, each of which accepts an integer parameter and assigns it to the corresponding color component. the class, alphachannelcolor-- a subclass of color-- has an integer instance variable, alpha, containing the alpha channel value, representing the degree of transparency of the color. alphachannelcolor also has a method named dissolve (void-returning, and no parameters), that causes the color to fade a bit. it does this by incrementing (by 1) all three color components (using the above accessor and mutator methods) as well as the alpha component value. write the dissolve method.
Answers: 2
question
Computers and Technology, 25.06.2019 06:50
The federal sentencing guidelines for organizations set the tone for organizational ethics compliance programs by question 1 options: a) codifying into law incentives for organizations to take action such as developing ethical compliance programs to prevent misconduct. b) forcing all organizations to develop mandatory reporting systems and ethics programs. c) eliminating most of the federal legislation that created inefficient and time-consuming activities for businesses. d) providing detailed guidelines for how to set up organizational ethics programs to guard against unethical conduct. e) providing a thorough examination of company codes of ethics to determine whether they are sufficient.
Answers: 1
You know the right answer?
141os is a very simple operating system that allows multiple users to save and print files. the 141o...
Questions
Questions on the website: 13722363