(Latest Revision:
April 26, 2021
)
Study Question Answers
Homework Assignment #1
Chapter #01 -- Introduction
- Question (#1) on Chapter #1:
Write 500 words or more describing the interplay between operating system
software and the interrupt mechanism. In your writing show that you
understand A) how interrupts "drive" the actions of the operating system,
and B) how the interrupt mechanism in a modern computing system actually
works (what hardware devices do to cause an interrupt and the sequence of
events that take place between the time that the currently running
program is interrupted and the time that program resumes
execution).
- Answer Ideas:
The essay could touch on some of these points:
- Operating system code does not execute continually. It executes only
when it is needed. After the boot sequence, the only thing that ever
causes OS code to execute is a software interrupt (trap) or a
hardware interrupt. That is why we say that the OS is
interrupt driven.
- In a modern operating system, a user process that needs to do I/O
makes a system call to request service from the OS. Typically it
does this by first placing parameters in locations where the OS will
be able to find them, and then executing a special system call
instruction that has the effect of interrupting the CPU.
- The interrupt causes a series of switches in the CPU to fire off.
The effect is to preserve context of the current process and then
cause the CPU to jump to operating system code for servicing the I/O
request.
- Typically the OS suspends the process P that requested the I/O. It
does this by inserting P's process control block (PCB) in a
wait-queue associated with the device that has to perform the I/O for
P.
- If the device is not busy, the OS requests an I/O operation, in
behalf of one of the processes in the wait-queue (which could be the
process P that just made the system call). Typically the OS makes
the request by writing values into registers within the controller of
the device and then triggering the start of the operation by sending
a signal on a control line of the system bus.
- After the OS makes an I/O request, the controller acts independently
of the OS until the I/O operation has completed.
- After putting P in the device queue and (possibly) making an I/O
request to the controller, the OS may take care of some system tasks
that need doing. Eventually the OS checks to see if the ready queue
is empty. If not, it schedules a process to run and dispatches it to
the CPU. If no processes are ready, the OS may do more system tasks,
or even execute a 'busy loop' temporarily, until a hardware interrupt
comes in.
- After a device controller completes an I/O operation, it interrupts
the CPU. The effect of this kind of (hardware) interrupt is
basically the same as that of the system-call interrupt (trap)
described above. After preserving some context of the current
process, the CPU jumps into OS code for servicing the interrupt.
- In response to the interrupt, the OS may need to copy data from a
buffer in the controller to a buffer in primary memory owned by the
process P that requested the I/O.
- At that point P is probably ready to run, in which case the OS moves
it from the I/O wait-queue to the ready queue. Once in the ready
queue P will eventually be scheduled by the OS to run again in the
CPU.
- Typically the OS will then check to see if the wait-queue of the
device is empty. If not, the OS will select a process from the
queue and request the controller to perform its desired I/O
operation.
Homework Assignment #2
Chapter #02 -- Operating Systems Structures
- Question #1 on Chapter #2:
Using information gleaned from chapters one and two, write 500 words or
more describing the important functions and responsibilities of a modern
multi-user, time-sharing operating system.
- Answer Ideas:
The essay could touch on some of these points:
- Operating systems make for more efficient usage of the hardware -
helping to keep the CPU and I/O processors doing useful work more
often - thus helping make the computer more cost effective - making it
pay for itself.
- An OS makes the system more convenient for the user - for example by
taking over error-prone I/O tasks and providing high level commands
that the bare hardware can not provide.
- The OS provides a collection of services that are needed in common by
all or most programs, and thereby saves all the programmers using the
system from having to write code to perform those services -- which
would be a lot of extra work.
- Operating systems must
- schedule jobs for execution,
- load jobs into memory and set them to running,
- operate all the I/O devices on behalf of user programs,
- perform context switching in a multiprogramming or time-sharing
environment,
- manage memory allocation/deallocation for the various user
processes,
- facilitate the communication and synchronization of concurrent
processes that interact,
- maintain an on-line file system and all the accompanying
structure,
- handle swapping (medium term scheduling),
- do all the copying and memory allocation required by virtual
memory systems,
- help protect users from each other - for example it must prevent
user processes from accessing each other's primary and secondary
memory resources,
- protect OS resources from user processes, and
- protect network server processes from network-based attacks.
- Question #2 on Chapter #2:
Using information from section 2.7 write 250 words or more describing
several different approaches to designing operating system structure.
Discuss the advantages and disadvantages of each approach.
- Answer Ideas:
The essay could touch on some of these points:
- Operating System Structuring
- Some OS's are not very modular
- Some are built in layers to make them more modular.
- Each layer is only allowed to call upon layers beneath it for services.
- layered design facilitates testing.
- It's not easy to design layers so that a lower layer never
has to ask a higher layer for a service.
- Microkernel design puts just a few essential services (say process &
memory management plus process communication) in the kernel and the
rest is pushed to "user-level"
- A recent design innovation involves utilizing dynamically
loadable modules. There is a core kernel module resembling a
micro-kernel. The dynamic modules can communicate directly with
each other through well-defined interfaces.
- With microkernel architecture it becomes fairly easy (if not
maximally efficient) to emulate many different operating systems "on
top of" the microkernel. The idea is to interpret foreign system
calls with microkernel system calls.
Homework Assignment #3
Chapter #03 -- Processes
- Question (#1) on Chapter #3:
Write 500 words on the topic of programs and processes. Define what a
program is and what a process is. Explain what the
differences and similarities are between the two concepts. Explain
and/or speculate on what operating system data structures must be
employed in order to maintain and preserve a program. Answer the
same question for a process. Give attention to similarities and
differences regarding the data structures too. Use information distilled
from your readings of chapter 3 to help you answer this question, and add
whatever else you know that you think will be helpful. (Keep in mind the
"intended readership" described in the directions above.)
- Answer Ideas:
The essay could touch on some of these points:
- A program is a passive entity
- A program normally resides on disk and consists of a file or a set of
files.
- The OS uses ordinary file system structures such as directories,
indices, and file blocks to maintain the program.
- A program is a text.
- The format of the program file might include separate areas for the
program instructions, initialized data, instructions for allocating
un-initialized data, instructions for the linker, and instructions
for the loader.
- A process is an active entity.
- The text and initialized data of a process have been copied from the
program file to sections of primary memory.
- The text section of a process may have text that did not come from
the program itself -- additional code added by the linker.
- The process has memory allocations for heap, runtime stack,
un-initialized data, and various context variables that do not exist
in the program on secondary storage.
- The process embodies at least one "thread of execution" -- the
activity of sequential execution of the program.
- Characteristics of the process include the value of the program
counter and the current values of all the data variables and
registers of the process.
- A process is the activity that happens when a program is executed.
- A program is basically the set of instructions to be executed by the
process, together with some other information explaining how the
program instructions and data are to be laid out in the memory image
of the program.
Homework Assignment #4
Chapter #04 -- Threads
- Question (#1) on Chapter #4:
Rewrite the essay you wrote in answer to the question for chapter #03.
The directions are the same except that this time you must cover three
concepts: program, process, and thread. In addition
to adding information about threads, since you know more now you should
be able to improve on what you said before about programs and processes.
(500 words)
- Answer Ideas:
In addition to making the points discussed earlier about the
characteristics of programs and processes, this essay could touch on
some of these points:
- Many threads can share resources within one 'task' or
'heavy weight process'
- Threads need to have some resources to themselves:
unique id number, stack, program counter, registers, cpu
allocation.
- Groups of threads can share primary and secondary
memory, program text, I/O devices, and communication
endpoints.
- A 'traditional process' consists of a single thread
running in a task -- which is to say a single thread of
execution employing a single process context.
- A (multi-) threaded application (process) can consist of many
threads running within a task.
###########################################################################
###########################################################################