Settings and Admin Services September 6, 2002

10 pts

Open the settings window from the START menu. CLASSIFY the icons that you find there into groups: for instance, one group could be the i/o devices such as keyboard and mouse. Use as many different classes as you need to logically group all the Icons. An Icons like System and Administrative Services could each represent their own group as they offer a second level of selection settings. Once you have a group for every icon, list the group names AND write a description for the group that justifies why the icons are its members.

Chapters 1 & 2 September 11, 2002

15 pts.

Write and submit your answers to the following end-of-chapter questions:
1.5, 1.7
2.3, 2.4, 2.9

java warmup,

September 18, 2002

10 pts.

1. If you haven't done so already, acquire access to Blue Jay (http://www.bluej.org/download/download.html)
2. Run the two producer/consumer solutions (java code available at http://people.westminstercollege.edu/faculty/ggagne/aosc/index.html)
3. Describe the any differences that you can observe in their functioning.
4. zip file has two directories with both message and bounded buffer

Producer.java

MessageQueue.java

Server.java

Consumer.java

javafiles4.zip

Chapter 3

Answer and submit the following end-of-chapter questions: 3.5, 3.7 3.11, 3.15

Assembly Language

30 pts.

Install the TCL/Tk Interpreter and execute the jassem.tlc program that simulates assembly code execution. It will ask you to load a program and you have 5 to choose from (with .jas extentions). Review the lecture notes linked in the calendar entry. Presumably you could now program in this assembly language and construct your own source file. Describe the format that source files for this simulation must take (extend the lecture notes). Confirm your assertions by seeing what happens when you change the structure of any of the given source files. Turn in a report of what you learned and how you verified it.

ActiveTcl8.3.4.3-win32-ix86.exe

jassem.tcl

p1.jas

p2.jas

p3.jas

fact4.jas

Java--improve programs

30 pts.

You have made the shared buffer and message passing programs run. Now make the following changes to the program, run them, and report what you find:

1. Add a timer to the programs so that each will stop after 30 seconds. Note that the Server does nothing but start the Consumer and Producer threads when it is created. You will need to invent a way to stop these threads. They each run infinite loops, so you can initiate a timer to end the threads. However, what happens then?

2. When the Consumer and Producer objects exit, let each print how much was consumed (produced) and how many times there was nothing to consume.

3. Hint: Producer and Consumer are running on their own threads. They must come to a normal exit if you are going to print out what they did (else they have to communicate their actions to some other object). You should have observed in your first exercise that bounded buffer does the printing in the buffer object but message passing does the printing in Producer and Consumer objects. From the above we conclude that the Producer and Consumer processes must initiate their timed exit when each is constructed. If they are asleep when they are notified that their time is up, what happens?

Assembler pracdtice

50 pts.

The attached files are extracted from the UTK website referenced in the calendar. You have introduced yourself to the assembly language and the assembly simulator. Now I'd like to have you modify the fact4.jsm program which demonstrates recursion (multiple stack frames) so that instead of computing 4! you compute fib6, the sixth fibinacchi number, 8 (1,1,2,3,5,8,....). The recursion is not tail recursion but the following: fib(n)= fib(n-1) + fib(n-2) where fib(1)=1 and fib(2)=1.

Your main routine will start by loading 6 into register 0 and then it will make a call to subroutine fib copying the contents of register 0 to the stack as a parameter, and fib will leave its value on the stack in place of the parameter when it returns.

The logic of fib will be to test to see if the parameter is 1 or 2, and if so, to return 1 in the parameter location. If not, fib must make two calls to fib and add the two results. Therefore it needs to push two variables on the stack, n-1 and n-2, and jsr to fib. Upon return the contents of its two stack locations must be exchanged and another call to fib made. Upon return the two stack locations must be added and the sum placed in the original parameter location before returning. Upon return to main the parameter must be retrieved and left in register 0 (where the original 6 has long since been overwritten

Messagepassing

50 pts.

Exercise 5.9 on p. 132 asks that you revise the MessageQueue class on page 108. The encapsulated storage structure will be changed to add a SIZE constraint (we could replace the Vector with a circular array but it is not necessary). The mailbox instance will now need to keep a count of how many elements it has to know if it is full. send() and received() have to be rewritten so that send cannot be invoked when the mailbox is full or the received invoked when the mailbox is empty. The author suggests we use suspend() and resume() and he illustrates them in fig 5.9 (ClockApplet). In the shared buffer example the bock was a busy wait. This time we want to free the CPU to execute other threads.

One way to do this is to add methods sendPermission(Producer) and receivePermission(Consumer)to the MessageQueue class. If the mailbox is full, the SP method places the Producer reference in a Vector and suspends the producer thread. Similarly for RP. The receive method is then ammended to resume one suspend consumer. The receive method is also ammended to resume one suspended consumer.

The new methods have signature public void sendPermission(Thread producer) etc. and the call is made immediately before the send: mbox.sendPermission(this);
mbox.send(message);

Deposit your consumer, producer and messagequeue source files in the drop box after testing to see that they work with the Server class. Also deposit a file of your run output and an analysis of what you see there (how well does the program work?).

Chapters 4&5

18 pts

write detailed answers to question 4.2, 4.4, 4.5, 5.1, 5.3 and 5.6.

Java Scheduler

30 pts

The author provides the code for his round-robin scheduler. You run this scheduler by running TestScheduler. Think about what happens when you do this:

  1. the main method of a TestScheduler object begins to execute on a user thread.
  2. it starts an new thread running a new Schedular object, and then starts three TestThread objects, each runing on its own thread. Five threads are now sharing CPU cycles. Four of these threads are in infinte loops.
  3. the main method "adds" each of the TestThread threads to the Schedule object. What does this mean? What does the assembly-level program do to accomplish this? What difference does it make if you DON’T add one of the threads to the Schedule object (modify and run the code and compare). The TestScheduler thread ends.
  4. Why does the Schedule thread sleep and none of the other threads do?
  5. In the scheduleSleep() method there is a call to Thread.sleep(). Explain why the call to a static method instead of this.sleep() [try the alternative].
  6. Explain the while loop in Scheduler. It does queue.getNext() infinitely. No threads are ever removed from the queue. Under what circumstances will a null be retrieved? Why the test for isAlive()? What happens while the scheduler is asleep?
  7. modify the program so that addThread sets the priority to 3. Describe how the program runs differently.
  8. modify addThread so that the priority is set to 5. How does that change how the program runs?

Do the above experiments and answer the questions posed.

Chapter 6

24 pts

Write responses to questions 6.1, 6.2, 6.3, 6.4, 6.6, 6.7, 6.8, and 6.9

Improve Scheduler

50 pts

Make the following changes to the past Java programs you have written:

  1. add isEmpty() and delete() to CircularList where delete removes the current item from the list (the one last returned by getNext(): index-1). If the list is empty delete does nothing
  2. modify the Scheduler class so that if its queue is empty it exits.
  3. change add addThread so its signature becomes public void addThread(Thread t, int priority). Be sure that the priority is <6 before changing t's priority.
  4. Let the Server class create a Scheduler object and place two Producer and three consumer threads in the queue (each with lifespan 30 seconds,) each consumer with priority 2 and each producer with priority 3.

Run the Server class several times with three consumer and two producer threads but without the Scheduler, and then execute several times the version of Server class that employs the Scheduler. Compare the results. Does everything work as expected?

Multi-level Scheduler

50 pts

Modify the Scheduler class as describe in 6.13. To test the new scheduler use 30 second consumer and producer threads where the addThread method now places its thread in queues 2, 3, 4,or 5. Scheduler should exit when all queues are empty and should use the delete() method of CircularList to remove expired threads from the queue. Run this version and the previous version of Scheduler with the same Server and see if the output is the same or different. Submit your code and your report of whether it is an improvement.

Chapter 7

40 pts

Fix the MessageQueue class as suggested in 7.2

More in 7

15 pts

Research and answer questions 7.4 and 7.9

Chapter 9

30 pts

Answer questions 9.5, 9.6, and 9.9. In addition, consider the data in problem 6.4 again but this time from the point of view of CPU utilization. Assume that instead of burst time, the numbers in that column represent quanta of CPU time needed in addition to io, and that each process will spend four times its calculation time waiting for io. P1 is the longest job, 8 quanta, but it will spend an additional 32 quanta in the io queue, so it takes a minimum (if no other jobs were available) of 40 quanta to complete. Assume that io is distributed evenly, so that on average, each process runs only for .2 quanta before requesting io (40 x .2 = 8). When there is another job available when P1 is suspended, it will be run, but it also stops for io. When there is no job available, the system idles. For these three jobs, how much of the time until they have all completed will the system have been idling? This illustrates that more jobs could have been done if they were available during this time, hence that multiprogramming makes the CPU more productive.

more on memory

30 pts

Answer questions 9.16, 10.2, 10.3, 10.9, 10.11, 10.17

paging and files

30 pts

Answer questions 10.18, 1.19, and 10.20 and also questions 11.8, 11.9, 11.10 and 11.13. When asked to compare, evaluate, or discuss, you should mention pros and cons, strengths and weaknesses, sample situations that are handled well by the OS and those handled poorly. More than one sentence is expected.

file systems

20 pts

Answer questions 11.14, 11.15, 11.17 11.20, and 11.22.

I/O systems

16 pts

write responses to questions 12.2, 12.5, 12.8 and 12.10.