Operating Systems 1

Tutorial 1

  1. Why (historically) were operating systems introduced? Do(es) the same reason(s) apply today?
    Traditionally, OSs introduced to efficiently use machine: allow many users to use same machine, load batch jobs faster than a human operator.

    Nowadays more important to hide the hardware from applications software, and allow user to run multiple programs, etc. (Make user more efficient, less so the machine.)

  2. "PCs, unlike mainframe computers, do not need a multi-user operating system." Agree or disagree? Why?

    Agree? PCs are 'personal computers', only one user.

    Disagree? PCs are often shared in offices, in the home. Often networked, so other people and programs access the 'personal' computer. Also, the idea of protected processes is useful when running untrusted code (but it's not something I mentioned in the lectures).

  3. Would you consider the 'filesystem' to be part of the operating system? In what sense is the file system an integral part of the OS? Under what circumstances would a file system definitely not be part of the OS?
    Another 'matter of opinion' one, really.

    For: filesystem code often part of the OS kernel. More compellingly: OS provides filesystem model. In UNIX, and other OSs with a unified filesystem namespace (all files, directories and devices in the same tree), OS is responsible for integrating the filesystems into the same (virtual file system) tree.

    Against: filesystem code often not part of OS kernel, and runs in user space (esp. modern OSs, like Linux and Plan9). Or NFS (Network File System), which is not even in the same computer, let alone built into the operating system.

  4. What might be an example of a 'process' on a Windows PC?
    Oh, lots of things: "Windows Explorer", programs like "Word", "Netscape". DOS commands like "DIR", "FORMAT". Applets and accessories, like calculators, like the program which sits in the background and waits for CDs to be inserted. Remember that each instance of, e.g. the calculator program, is a different process.
  5. Why must the processor registers be stored when a task-switch occurs?
    (Because the process might be using the registers and otherwise they'd get mangled...)

    So that the next time a process gets a go on the CPU, the state of the machine is exactly as it was when the process was preempted. It is important that each process may ignore the fact that the OS is switching rapidly between it and other processes.

  6. What is meant by the term 'virtual machine'? Why is it a useful model?

    A virtual machine is... central to computer science... How to explain it?

    It's a model of a machine which is presented to client software by lower-level software.

    The 'virtual machine' presented to a process in a multitasking system is one in which it has the processor and a big lump of memory to itself, and in which there are no interrupts or suchlike hardware details.

    It is useful because it allows a simpler model (than reality, which is messy) to be presented to higher-level software.

  7. What are the advantages of a 'layered' operating system? What are the disadvantages?

    Advantages: modularisation of code (over 'monolithic' design)---clear demaraction of responsibility. Better security: each layer only trusts the layer below it.

    Disadvantages: still 'monolithic'---difficult to extend. System calls may be expensive if they drill down several layers.

  8. The number of functions and facilities on modern operating systems is large and growing. Why might a 'microkernel' architecture be appropriate in this context.

    Microkernel architecture moves all but the most fundemental services out of the kernel into user-level processes. With operating systems expected to perform more and more jobs, moving services into processes outside the kernel

    • lets the kernel concentrate on its job---makes it smaller, more efficient, more reliable.
    • allows the OS to be extended easily (just add new server processes).
    • better security: server processes need not be an entangled mess of trusted code. Bugs in one process don't trash other processes.
  9. Give an example of a 'server' process in a microkernel operating system.

    File server (local or network).

    VM server---handles mapping files and swapping out pages to disk.

    Display server---like X-Window.

    Process server. (It's in the book. I have no idea what it would do.)

    Various device drivers.

  10. Many (most) modern CPUs have a 'user' mode and a 'supervisor' ('kernel') mode. Early versions of the Macintosh OS did not make use of 'user' mode (and ran all applications code in supervisor mode). What would have been the reasons for changing the design (to make use of user mode)?

    Using user mode ensures that certain operations are not available to user-level programs. For example: switching off interrupts, buggering with the memory management unit (which would allow access to other processes' memory), turning the processor off.

  11. If a system has only one CPU, what does it mean to say that two tasks are 'concurrent'?
    Means the processer is switching between them rapidly, giving the illusion of concurrency.
  12. What does the 'dispatcher' do in a multitasking system. How is it different from the 'scheduler'?

    Dispatcher loads the new process state into the machine registers and switches to user mode. (It launches the new process after a task switch.)

    The scheduler makes the executive decision about which process to run next (which process the dispatcher should dispatch).

  13. What circumstances trigger a call to the scheduler and dispatcher?
    1. Certain system calls (esp. blocking system calls).
    2. At the end of an interrupt service routine.

    also:

    1. When a process dies (completes its task).
  14. Neither 'blocked' processes and 'runnable' processes are currently running on a CPU. What is the difference between them? What might cause a 'blocked' process to become 'runnable'?

    Runnable processes are ready to take on the processor at a microsecond's notice. They have something to do now.

    Blocked processes are waiting for an event---for a resource to become available, for some data to be delivered, for a semaphore to become non-zero. They can't run even if the processor has nothing better to do.

  15. What is a 'critical section'? Can 'race conditions' occur in a single-tasking system?
    A 'critical section' is a region of code which makes some non-atomic update to a data structure which may be accessed by other processes. It isn't a critical section if the code within is atomic. It isn't a critical section if there's only ever one process accessing/updating the same structure/variable. ('Critical section' implies possible race condition.)

    No, race conditions only occur when there are multiple concurrent processes.

    (Race conditions should not occur in a cooperatively-multitasking system---except if the programmer is really careless---since the current process controls when the next task switch occurs...)