This tool is designed to save you time by giving a simple way to print out nicely formatted information about the state of the processes on your system. It should, perhaps, more aptly be named "process_printer". To use the printer, you repetitively do the following:
The ultimate goal is to have a simple and compact way to display what the scheduler and various processes are doing at any point in time.
SP_setup is called in order to define the various items that will be printed. It is called with many different modes, the general format being SP_setup( mode, data ); mode is one of the mnemonics described below. Data can be any of the following three types:
1. SP_FILE_MODE assumes a pointer to a type FILE
FILE *file_ptr;
SP_setup_file( SP_FILE_MODE, file_ptr );
2. SP_ACTION_MODE assumes a pointer to a string is being passed.
char action[SP_LENGTH_OF_ACTION];
SP_setup_action( SP_ACTION_MODE, action );
3. ALL OTHER modes assume that a long value is being passed.
long current_time;
SP_setup( SP_TIME_MODE, current_time );
Here are the various modes, and a brief description of how they are used.
NOTE: The various modes that define PIDs in states can be called multiple times per printout.
NOTE: After an SP_print_line is executed, all the state information ( except the file data ) is nullified.
Format: SP_print_header();
This string is printed out when requested as a header:
"Time Target Action Running New DONE State Populations"
The string is defined in the include file syscalls.h.
Format: SP_print_line();
This routine prints out all the data that has been defined using SP_setup. It also nullifies this data, initializing the printer for the next set of definitions. Here is an example of the output:
Time | Target | Action | Run | New | Done | State Populations |
99999 | 99 | Schedule | 53 | 50 | 80 | READY: 0 1 2 3 4 5 6 7 8 9 |
WAITING: 20 21 22 23 24 25 26 27 28 29 | ||||||
SUSPEND: 30 31 32 33 34 35 36 37 38 39 |
The output generated from running your operating system can be overwhelming. The amount of data produced is abundant and in an effort to reduce the amount of paper you turn in, here are a few guidelines.
The output from your operating system comes in 3 categories, a) Scheduler Output, b) Output from the tests you ran, and c) Error and Trap handling. The requirements on what you are to hand in varies for each test. See the student manual for a detailed list.
Each of these categories are addressed below.
Attached is a sample output using code similar to scheduler_printer.c provided to you. This is meant to be an example, but you should use this sample as a model and provide your output in a similar format.
The scheduler has five actions that should be logged (you may have more); Dispatch, Create, Done (or Terminate), Ready, and Wait.
By adding a variable(s) to your PCB, you can control how a process is logged. In this example, only 3 Dispatches are logged for each process, subsequent dispatches are not logged. You should have a higher limit (perhaps in the 5-10 range).
All Create and Done actions are logged for each process.
A similar mechanism used for dispatch logging should be used for the Ready and Wait actions. In the example, Ready and Wait actions are not logged.
When a process is SUSPENDED or has its priority changed, you should reset your logging variable(s) in the PCB, so that these changes to the process can be seen.
You should highlight interesting things in your output, for example: if a process is suspended and resumed, or a change in priority.
The results from all test programs should be handed in, in their entirety. For the tests provided to you, there is not a lot of output produced.
This section includes interrupt, fault, and SVC handling.
As you will see, this can be a lengthy amount of output. You should hand in enough output to demonstrate the proper handling of these errors and traps.
Consider using a similar scheme as the scheduler to show some error and trap handling, then disable it after some threshold has been exceeded. Whatever you set as a threshold, be sure it is high enough to show several instances of all the actions that might occur; in general if you set the threshold so all of test1a is displayed, you'll be OK.
Here is an example of the output from scheduler_printer.
Time | Target | Action | Run | New | Done | State Populations |
20 | 0 | Create | 0 | READY: | ||
WAITING: | ||||||
20 | 0 | Dispatch | 0 | READY: 0 | ||
WAITING: | ||||||
68 | 1 | Create | 1 | READY: 0 | ||
WAITING: | ||||||
101 | 1 | Done | 1 | READY: 1 0 | ||
WAITING: | ||||||
104 | 0 | Dispatch | 0 | READY: 0 | ||
WAITING: |
** Last time Process 0 'Dispatch' will be logged. **
Time | Target | Action | Run | New | Done | State Populations |
127 | 1 | Create | 1 | READY: 0 | ||
WAITING: | ||||||
155 | 2 | Create | 2 | READY: 1 0 | ||
WAITING: | ||||||
183 | 3 | Create | 3 | READY: 1 2 0 | ||
WAITING: | ||||||
211 | 4 | Create | 4 | READY: 1 2 3 0 | ||
WAITING: | ||||||
239 | 5 | Create | 5 | READY: 1 2 3 4 0 | ||
WAITING: | ||||||
267 | 6 | Create | 6 | READY: 1 2 3 4 5 0 | ||
WAITING: | ||||||
295 | 7 | Create | 7 | READY: 1 2 3 4 5 6 0 | ||
WAITING: | ||||||
323 | 8 | Create | 8 | READY: 1 2 3 4 5 6 7 0 | ||
WAITING: | ||||||
427 | 0 | Done | 0 | READY: 1 2 3 4 5 6 7 8 0 | ||
WAITING: | ||||||
430 | 1 | Dispatch | 1 | READY: 1 2 3 4 5 6 7 8 | ||
WAITING: | ||||||
471 | 2 | Dispatch | 2 | READY: 2 3 4 5 6 7 8 1 | ||
WAITING: | ||||||
518 | 3 | Dispatch | 3 | READY: 3 4 5 6 7 8 1 | ||
WAITING:2 | ||||||
565 | 4 | Dispatch | 4 | READY: 4 5 6 7 8 1 2 | ||
WAITING:3 | ||||||
612 | 5 | Dispatch | 5 | READY: 5 6 7 8 1 2 3 | ||
WAITING:4 | ||||||
659 | 6 | Dispatch | 6 | READY: 6 7 8 1 2 3 4 | ||
WAITING:5 | ||||||
706 | 7 | Dispatch | 7 | READY: 7 8 1 2 3 4 5 | ||
WAITING:6 | ||||||
747 | 8 | Dispatch | 8 | READY: 8 1 2 3 4 5 | ||
WAITING:67 | ||||||
891 | 1 | Dispatch | 1 | READY: 1 2 3 4 5 6 7 8 | ||
WAITING: |
** Last time Process 1 'Dispatch' will be logged. **
Time | Target | Action | Run | New | Done | State Populations |
941 | 2 | Dispatch | 2 | READY: 2 3 4 5 6 7 8 | ||
WAITING: 1 |
** Last time Process 2 'Dispatch' will be logged. **
Time | Target | Action | Run | New | Done | State Populations |
991 | 3 | Dispatch | 3 | READY: 3 4 5 6 7 8 1 | ||
WAITING: 2 |
** Last time Process 3 'Dispatch' will be logged. **
Time | Target | Action | Run | New | Done | State Populations |
1041 | 4 | Dispatch | 4 | READY: 4 5 6 7 8 1 2 | ||
WAITING: 3 |
** Last time Process 4 'Dispatch' will be logged. **
Time | Target | Action | Run | New | Done | State Populations |
1091 | 5 | Dispatch | 5 | READY: 5 6 7 8 1 2 3 | ||
WAITING: 4 |
** Last time Process 5 'Dispatch' will be logged. **
Time | Target | Action | Run | New | Done | State Populations |
1141 | 6 | Dispatch | 6 | READY: 6 7 8 1 2 3 4 | ||
WAITING: 5 |
** Last time Process 6 'Dispatch' will be logged. **
Time | Target | Action | Run | New | Done | State Populations |
1191 | 7 | Dispatch | 7 | READY: 7 8 1 2 3 4 5 | ||
WAITING: 6 |
** Last time Process 7 'Dispatch' will be logged. **
Time | Target | Action | Run | New | Done | State Populations |
1241 | 8 | Dispatch | 8 | READY: 8 1 2 3 4 5 6 | ||
WAITING: 7 |
** Last time Process 8 'Dispatch' will be logged. **
Time | Target | Action | Run | New | Done | State Populations |
11428 | 1 | Done | 1 | READY: 1 2 3 4 5 6 7 8 | ||
WAITING: | ||||||
11462 | 2 | Done | 2 | READY: 2 3 4 5 6 7 8 | ||
WAITING: | ||||||
11496 | 3 | Done | 3 | READY: 3 4 5 6 7 8 | ||
WAITING: | ||||||
11530 | 4 | Done | 4 | READY: 4 5 6 7 8 | ||
WAITING: | ||||||
11564 | 5 | Done | 5 | READY: 5 6 7 8 | ||
WAITING: | ||||||
11598 | 6 | Done | 6 | READY: 6 7 8 | ||
WAITING: |