The operating system should execute as many programs as possible. In particular, if one program fails due to some error condition, the operating system should throw it out and continue to tend to the other running programs (if any). Under no circumstances should a failing program cause the operating system itself to fail.
The index block - disk block 0, the first block on the disk - contains an index of the programs in the disk. The ith word of the index block contains the size in disk blocks of the ith program in the batch disk. Unused entries in the index block are set to zero. Every batch disk contains an index block.
For example, this diagram
shows a batch disk containing three programs. The first program has size 3; that is, the first program occupies three disk blocks. The second program has size 1 and the third program has size 2.
A program is loaded in User Space in order of increasing addresses. The
contents of the program's first disk block is loaded into User Space starting at
location i; the contents of the program's second disk block is loaded into
User Space starting at location i + disk_block_size
; and so on. The
program's blocks must all fit in User Space. A program may be loaded anywere in
User Space it can fit.
Once loaded into primary storage, the program's first instruction has address i, the address of the first word of the program. The program counter should be set to i when the program first executes.
After boot-up initialization, the operating system should load and begin executing the first program on the batch disk; word 0 of the index block contains information on the first program. If the batch disk contains no programs, the operating system should halt.
fork
,
join
, and exit
. These are the first of many system calls you will be
implementing in these assignments, so you might want to give some though to
designing an easily changeable system-call implementation (or you have to be
willing to throw-away and rewrite your system-call implementation several
times, which is probably the better approach to take).
system_call::exit
)The exit value is the value returned in a join system call.
system_call::fork
)After the fork system call returns, register 0 contains the system call status
status::ok | command completed successfully |
status::bad_id | there is no program with the given id |
and register 1 contains an identifier for the newly created process.
A fork system call copies the contents of registers 0 through 10 from the parent to the child when creating the child. When the child begins execution, the contents of its registers 0 through 10 are identical to the contents of the parent's registers at the time the parent made the fork system call. After the fork, the register contents could differ as the parent and child change them independently of one another.
system_call::join
)After the join system call returns, register 0 contains the system call status
status::ok | command completed successfully |
status::bad_id | there is no process with the given id |
If register 0 contains status::ok
, then register 1 contains the value the
joined process passed in register 1 for the exit system call. The
contents of register 1 is undefined if register 0 contains a value different
from status::ok
.
A process may join with a process that has exited before the join system call. A process may be the target of at most one join statement.
If more than one process is trying to join with the same process, exactly one
of the joining processes will win and the rest will lose. The choice if the
winner is arbitrary among the joiners. The losing processes have
status::bad_id
codes in register 0.
/export/home/class/cs-438-505/pa1
contains some batch disks you can use to test
your operating system:
pa1-empty.dsk
- The empty disk; it contains no programs.
pa1-solo.dsk
- A disk containing a single program that just makes an
exit system call.
pa1-forks.dsk
- A disk containing programs that just fork and exit
without doing any joins.
pa1-forkjoin.dsk
- A disk containing program that forks and joins with
another program.
pa1-tree.dsk
- A disk containing program that forks into a
fifteen-process complete binary tree and then joins back to a single process,
passing values up and down the tree.
pa1-bad.dsk
- A disk containing programs that do bad things.
My solution to the first programming assignment, os1
, is available in
/export/home/class/cs-438-505/misc
. You should not be concerned about matching your operating system's
timing to the timings from os1
; timing varies depending on implementation
details. However, the SYSC
system-call instruction counts - obtained with
the ins_cnts
flag - from your operating system should
match exactly the instruction counts from os1
.
If you're looking for a way to proceed, you might want to consider the following steps:
This page last modified on 28 June 2002.