the operating systemlblopes/aulas/ic/t11.pdf · on the pdp-7, in 1969, a team of bell labs...
TRANSCRIPT
THE OPERATING SYSTEM
On the PDP-7, in 1969, a team of Bell Labs researchers led by [Ken] Thompson and [Dennis] Ritchie, […], developed a hierarchical file system, the concepts of computer processes and device files, a command-line interpreter, and some small utility programs. The resulting system […] was to become
Unix.
(source: Wikipedia)
UNIX features and capabilities
• centralised kernel manages resources and processes
• multitasking and multiuser
• programming interface (libraries and shell)
• hierarchical file system
• everything is a file
• built-in networking
• persistent system services called "daemons"
UNIXINTERNALSTRUCTURE
• process scheduling: which process has access to the CPU? when does it halt? which comes next?
• memory management: can a process be allocated in main memory? if so, where?
• file system: access to files translated into I/O requests for devices.
• device control: load/store data from/to devices to/from memory.
typical kernel functions
how is the OS kernel loaded into memory?
BIOS (BASIC I/O SYSTEM)
complete boot process (Linux)
Process Management
Process Control Block (PCB)
• one per process• holds fundamental information about a process• required to stop it and to make it run again• information includes:
1. process state (e.g., running, suspended)2. process ID3. program counter4. contents of registers5. location of address space6. ID of open files7. and more…
• updated when process (re)starts & when it stops
Process Queues
• the operating system has several process queues
• each queue has PCBs for processes
• typically there is a ready queue
• one queue per each I/O device that processes may be waiting on
operating systemprocessqueues
inmemory
• each process is assigned a time quantum• a process runs when it is taken from the front of the ready
queue• something happens when:
1. its quantum ends (moves to end of ready queue)2. it needs to perform I/O (moves to end of a device
queue)3. it forks a child (child moves to end of ready queue)4. it waits for an interrupt (moves to end of device
queue)• PCB is removed from queues when process exits
Process PCBs move between queues
The Process Cycle
Process Context Switch
File System
In a UNIX system the “file” is the basic unit of data storage
Everything is a file, including peripheral components
The file system is the way UNIX organizes files in mass storage devices such as disks
File systems are kept in sections of disks called partitions that have been previously prepared to hold them (formatted)
Creating such partitions is one of the operations that must be performed in preparation for the installation of an
operating system and its file systems
What is a file system?
The Unix file system is hierarchical
Memory Management
the basic execution unit of a UNIX operating system is the process
a binary executable file becomes a process when it is loaded by the operating system loader into memory
the loader assigns it an exclusive address space and copies part of it into main memory
at any time a UNIX operating system may have many processes in the ready or device queues
part of the code and data for these processes must be available in the main memory of the computer
since the size of the main memory is much smaller than the size of the storage devices (usually HDD or SSD with hundreds of MB or a few TB) it follows that only part of
the total information is at any time in memory
to keep all the processes running it is often required that some space is freed in memory by temporarily removing data from one process to be filled by data from another
this operation involves the transfer of information between memory and disks and is called swapping
to be able to do this, the operating system must implement a memory management system that keeps track of which processes have information in memory
for any given process only a small part of its address space will be in the main memory at any given time
more information from the process is transferred from the disks to the main memory as it is required (e.g., a jump to a function whose code is not in memory yet)
when information is requested, during the execution of a process, that is not currently in the main memory, the operating system must provide it, eventually swapping
some information out
one of the memory management techniques used is called virtual memory and allows the execution of processes whose code/data segments are greater than the physical
limits of main memory
the two main flavours of virtual memory are called pagination and segmentation
Interrupts
the cpu die is packaged within a protective plastic/ceramic cocoon and communicates with motherboard through pins
the cpu die is connected to pins through internal wiring (here Intel 80486)
the microprocessor exchanges data with the outside and is fed energy through these pins
the microprocessor is interrupted some times, in response to external events, namely:
• timer alarms (e.g., context switch)• input/output requests from devices• hardware or power failures
interrupts have associated (integer) identifiers that identify the type of event
they signal
interrupt - an unexpected change in control flow in a program that happens independently of the program being executed, e.g., I/O requests, memory errors, power supply failure
I/O and Device Control
devices are represented as files in /dev
access to these files triggers special low-level programs called device drivers that allow the operating system to setup and execute I/O operations on the device
there are several types of devices:character — e.g., /dev/tty — teclado, rato, displays
bulk — e.g., /dev/disk0 — HDD, SSD, DVDnetwork — placa de rede
pseudo devices — /dev/null
data in block devices is often organized into filesystems, of which there are many kinds:
ufs2 — Unix File Systemext2,ext3, ext4 - Extended File System
reiserfs - Reiser File Systemjfs — Journaled File Systemzfs — Zettabyte File System
these differ in features like: the maximum size of the filesystem, support for journaling, support for
compression and data protection
I/O devices have hardware circuitry called controllers that allow the operating system to control them by issuing low level commands
an SSD inside with the Flash memory modules and the controller hardware (left)
the device drivers provide an API to the operating system to control the device and
perform I/O operations
I/O requests involve transfer of data from devices to/from main memory signalled by interrupts
on receiving an interrupt, the CPU stops, calls the corresponding handler that initiates the I/O and
transfers control to the device controller
the CPU returns immediately from the handler and continues with the interrupted process (or suspends
it if the process itself is waiting on the I/O)
when the I/O transfer is complete the controller sends an interrupt to the CPU, acknowledging the
termination or the occurrence of an error