- Information
- AI Chat
Chapter 1
Computer Science (CSC1B)
University of Johannesburg
Recommended for you
Preview text
Introduction
Computers are equipped with a layer of software called the operating system, whose job is to provide user programs with a better, simpler, cleaner, model of the computer and to handle managing all the resources.
The program that users interact with, usually called the the shell when it is text based and and the GUI(GRAPHICAL USER INTERFACE).
The operating system is the most fundamental piece of software and runs in kernel mode or supervisor mode. In this mode it has complete access to all the hardware and can execute any instruction the machine is capable of executing. The rest of the software runs in user mode, in which only a subset of the machine instruction is available.
Where the OS fits in
Levels of abstraction
● Software is often implemented in layers. ● The higher levels use the facilities provided by lower layers. ● Alternatively said, the upper layers are written using a more powerful and more abstract virtual machine than the lower layers. ● Alternatively said, each layer is written as though it runs on the virtual machine supplied by the lower layer and in turn provides a more abstract virtual machine for the higher layer to run on. ● In a broad aspect, the layers are:
- Applications and utilities
- Compilers, Editors, Command Interpreter(shell, DOS prompt)
- Libraries
- The OS proper (the kernel, runs in privileged/kernel/supervisor mode)
- Hardware ● Compilers, editors, shell, linkers, etc run in user mode. ● The kernel itself it itself normally layered, e.
- Filesystems
- Machine independent I/O
- Machine dependent device drivers ● The machine independent I/O part is written assuming “virtual hardware(idealised)”.
What is an operating system? h 1,
The kernel itself raises the level of abstraction and hides details. For example a user (of the
kernel) can write to a file and ignore whether the file resides on a floppy, a CD ROM, or a
hard magnetic disk.
The kernel is resource manager users don’t conflict.
A modern computer consists of the following:
● One or more processors
● Main memory (primary storage)
● Disks (secondary storage)
● varios I/O devices
Managing all the components above required a layer of software called the operating
system.
One of the major tasks of the operating system is to hide the hardware and present
programs
History of the OS h 3
Generations:
●
● (1945 55) vacuum tubes Single user no OS ● (1955 65) transistors and batch systems The OS now must protected from the user program so that it is capable of starting( and assisting) the next program in the batch. Batch system the idea behind it was to collect a tray full of jobs in the input room and then read them onto a magnetic tape using a small (relatively) inexpensive computer.
Second generation:
● (1965 80) ICs and multiprogramming 1. The purpose was to overlap CPU and I/O 2. Multiple batches ● IBM OS/MFT (Multiprogramming with a Fixed number of Tasks) 1. OS for IBM system 360 2. The (real) memory is partitioned and a batch is assigned to a fixed partition 3. The memory assigned to a partition does not change 4. Jobs were spooled from cards into the memory by a separate processor (an IBM 1401). Similarly output was spooled from the memory to a printer (a 1403) by the 1401 ● IBM OS/MVT (Multiprogramming with a Variable number of Tasks) 1. Each job gets just the amount of memory it needs. That is, the partitioning memory changes as jobs enter and leave 2. MVT is more “efficient” user of resources, but is more difficult 3. When we study memory management, we will see that, with varying size partitions, questions like compaction and “holes” arise 3. Time Sharing ● This is multiprogramming with rapid switching between jobs (processes). Deciding when to switch and which process to switch to is called scheduling
.
● (1980 present) the personal computer (PC) 1. Serious PC operating systems such as linux, windows NT/2000/xp and MacOS are multiprogrammed OSes. 2. GUIs have become important. Debate as to whether it should be part of the kernel 3. Early PC operating systems were uni programmed and their direct descendents in some sense still are (e. windows ME)
CPU pipe-lining
● A three stage pipeline Many modern CPU’s have facilities for executing more than one instruction at the same time. For example, a CPU might have separate fetch, decode, and execute units. so that and while it was executing instruction n, it could also be decoding instruction n+1 and fetching instruction n+2 (Figure a). mechanism for executing instructions, multiple at the same time that is. ● Superscalar CPU More advanced than a pipeline design (Figure b), in this design, multiple execution units are present. For example, one integer arithmetic, one for floating point arithmetic, and one for Boolean operations. Two or more instructions are fetched at once, decoded and dumped onto a holding buffer until they can be executed. As soon as an execution unit is free, it looks in the holding buffer to see if there is an instruction it can handle, and if so, it removes the instruction from the buffer and executes it. Downfall instructions could be executed out of order.
To obtain services from the operating system, a user program must make a system call, which traps into the kernel and invokes the operating system. When the work has been completed, control is returned to the user program at the instruction following the system call.
Multithreaded and Multicore Chips
● Figure a ○ possible bottleneck, ○ cheap, ○ less independence ● Figure b ○ higher independence, ○ expensive
Multithreading OR hyperthreading It allows the CPU to hold the state of two different threads and then switch back and forth on a nanosecond timescale. For example, if one of the processes needs to read a word from memory, a multithreaded CPU can just switch to another thread. Multithreading does not offer true parallelism. Only one process is running at a time, but thread switching time is reduced to the order of a nanosecond Implications for the operating system because each thread appears to the operating system as a separate CPU. Consider a system with two actual CPU’s, each with two threads. The operating system will see this as four CPUs. May inadvertently schedule two threads on the same CPU, with the other CPU completely idle, this is far less efficient.
● Magnetic tapes ○ used for backup ○ very large data sets ○ slow
I/O Devices
How does the OS know when the I/O is complete? ● It can busy wait constantly asking the controller if the I/O is complete. This is the easiest (by far) but has low performance. It is also called polling or PIO (Programmed I/O). ● It can tell the controller to start the I/O and then switch to other tasks. The controller must then interrupt the OS when the I/O is done. Less waiting, but harder (concurrency!). Also on modern processors a single is rather costly. Much more than a single memory reference, but much, much less than a disk I/O. ● Some controllers can do DMA (Direct Memory Access) in which case they deal directly with memory after being started by the CPU. This takes work from the CPU and halves the number of bus accesses.
The Operating System Zoo h 5
There is not as much difference between mainframe, server, multiprocessor, and PC OSes as Tannenbaum suggests. For example Windows NT/2000/XP, Unix and Linux are used on all. ● Mainframe Operating Systems ○ Used in data centers, these systems offer tremendous I/O capabilities and extensive fault tolerance. ● Server Operating Systems ○ Perhaps the most important servers today are web servers. Again I/O (and network) performance are critical. ● Multiprocessor Operating systems ○ These existed almost from the beginning of the computer age, but now are not exotic. ● PC Operating Systems (client machines) ○ Some OSes (e. Windows ME) are tailored for this application. One could also say they are restricted to this application.
● Real time Operating Systems
○ Often are Embedded Systems ○ Soft vs hard real time. In the latter missing a deadline is a fatal error ○ Very important commercially ● Smart Card Operating Systems ○ Very limited in power ● Handheld Computer Operating System ○ small computer ○ sophisticated operating system Multiple computers: ● Network OS: Make use of the multiple PCs/workstations on a LAN ● Distributed OS
You can name a file via an absolute path starting at the root directory or via a relative path starting at the current working directory.
In addition to regular files and directories, Unix also uses the file system namespace for devices (called special files, which are typically found in the /dev directory. Often utilities that are normally applied to (ordinary) files can be applied as well to some special files.
Files connected via pipes
There are a wide variety of I/O devices that the OS must manage. For example, if two processes are printing at the same time, the OS must notinterleave the output. The OS contains device specific code (drivers) for each device as well as device independent I/O code
System calls h 14, 18
System calls are the way a user (i., a program) directly interfaces with the OS.
- Push third parameter on to the stack.
- Push second parameter on to the stack.
- Push first parameter on to the stack.
- Call the library routine, which involves pushing the return address on to the stack and jumping to the routine.
- Machine/OS dependent actions. One is to put the system call number for read in a well defined place, e., a specific register. This requires assembly language.
- Trap to the kernel (assembly language). This enters the operating system proper and shifts the computer to privileged mode. Assembly language is again used.
- The envelope uses the system call number to access a table of pointers to find the handler for this system call.
- The read system call handler processes the request.
- Some magic instruction returns to user mode and jumps to the location right after the trap.
- The library routine returns (there is more; e., the count must be returned)
- The stack is popped (ending the function call read).
A major complication is that the system call handler may block. Indeed for read it is likely that a block will occur. In that case a switch occurs to another process.
Memory Layout
Processes in UNIX have their memory divided up into three segments: text segment(program code), the data segment(variables) and the stack segment. The date segment grows upwards and the stack grows downward. Between them is gap of unused address space. The stack grows into the gap automatically, but expansion of the data segment is done explicitly by using a system call.
Linking
When the compiler and assembler have finished processing a module, they produce an object module that is almost runnable. There are two remaining tasks to be accomplished for the object module to be runnable. Both are involved with linking) together multiple object modules. The tasks are relocating relative addresses and resolving external references.
Mounting
By executing the mount system call, a file system can be attached to the root filesystem.
Operating system structure h 23
Two main structures: Monolithic Systems: ● A main program that invokes the requested service procedure. ● A set of service procedures that carry out the system calls. ● A set of utility procedures that help the service procedures Layered Systems:
Client server:
When implemented on one computer, a client server OS uses the microkernel approach in which the microkernel supplies just interprocess communication, and the main OS functions are provided by a number of separate processes. This does have advantages. For example an error in the file server cannot corrupt memory in the process server. This makes errors easier to track down. But it does mean that when a (real) user process makes a system call there are more processes switches. These are not free. A distributed system can be thought of as an extension of the client server concept where the servers are remote.
Virtual Machines: Use a “hypervisor” (beyond supervisor, i. beyond a normal OS) to switch between multiple Operating Systems. Made popular by IBM's VM/CMS
● Each App/CMS runs on a virtual 370. ● CMS is a single user OS. ● A system call in an App traps to the corresponding CMS. ● CMS believes it is running on the machine so issues I/O. instructions but ... ● ... I/O instructions in CMS trap to VM/370. ● This idea is still used. A modern version (used to “produce” a multiprocessor from many uniprocessors) is “Cellular Disco”. ● Another modern usage is JVM the “Java Virtual Machine”.
Chapter 1
Course: Computer Science (CSC1B)
University: University of Johannesburg
- Discover more from: