<<

• Runs on a variety of , from notebooks to Lecture 17 supercomputers • Dominant for high-end and servers Case Study • It was carefully designed to be simple • In spite of its age it is still modern and elegant Unix • Many design principles came with, or from Unix • Many of these design principles have been copied by other systems • Many versions: BSD, AIX, HPUX, , Solaris, etc.

1 2

UNIX - UNIX - History

• 60s - general-purpose timesharing • Unix in a high-level language – MIT: CTSS – It was hard to rewrite Unix for each different – MIT, , and : machine – Bell Labs left – Languages available were not appropriate • decided to its own system in • CPL – BCPL – tag">B assembler to run on a PDP-7 • This system, UNICS, a smaller version of MULTICS, – Ritchie designed and wrote a for it was later called UNIX – Thompson and Ritchie rewrote UNIX in C • and other people joined the project – C became the standard language for systems since • UNIX was ported to other, powerful, PDP machines, (with 256KB and 2MB of memory) with then

3 4

UNIX - History UNIX Overview

• Unix got known – In 1974, Ritchie and Thompson published a • Interactive system landmark paper about UNIX • Designed to multiple processes and – In 1984, Ritchie and Thompson were given a Turing mutliple users the same award for the work described in that paper • Designed by for programmers – After the publication of that paper, universities • System is expected to be simple, elegant, and started asking for a of UNIX consistent – Bell Labs (part of AT& by then) was not permitted – Files should be just a collection of bytes in the business – Command should accept parameters in the same way – Bell Labs started licensing UNIX to universities for – The commands’ interface should be simple a small fee

5 6

1 UNIX Overview UNIX Kernel

User Interface • The layers of a UNIX system.

Approximate structure of generic UNIX kernel Interfaces and layers in a UNIX system

7 8

The UNIX Processes in UNIX

• The shell is a command line interface • Processes are the only active entities in a • UNIX does support a graphical environment (X UNIX system Windows) • In comparison with graphical interfaces, the shell • Processes run sequentially is more powerfull, faster to use, and easily • Processes can create additional threads extensible • UNIX is a multiprogramming system • Some examples – ch, csh, ksh, – Multiple independent processes may be running • The shell accepts command lines and starts at the same time processes to execute the corresponding commands

9 10

Processes in UNIX Processes in UNIX

(background) processes are always • Processes are created by a , running • The child is an exact independent copy of – Handle incoming and outgoing email the parent – Manage the queue • The child may turn itself into another – Check if there are enough free pages in memory by executing a system call – Etc.

11 12

2 Processes in UNIX Processes in UNIX

• Processes can comunicate through a channel • Processes can comunicate through signals called pipe • A process can send a to another • A process sends a of bytes to another process process through the pipe • A process can define what is supposed to be • Synchronization is possible because the done when a specific signal is received receiver process blocks waiting for data

13 14

POSIX Shell The Command

A highly simplified shell Steps in executing the command ls to the shell

15 16

UNIX Scheduler UNIX Scheduler

• Designed to provide good response to • Each version has a slightly different interactive systems algorithm to the generic one • 2-level algorithm • Generic low-level – Multiple queues – The low-level algorithm picks the process to – Each queue associated with a range of priorities run next – Processes executing in have positive values – The high-level algorithm moves processes – Processes executing in kernel mode have negative values between memory and disk – Negative values have higher priorities – Only processes that are in memory are in the queues

17 18

3 UNIX Scheduler UNIX Scheduler

• Generic low-level – The scheduler searches the queues starting at the highest priority – The first process found is dispatched – A process runs until it blocks or for 100msec (typically) – If a process uses its quantum, it is placed at the end of the queue – Once a second, each process’ priority is recalculated priority = CPU-usage + + base – Idea: get processes out of the kernel fast The UNIX scheduler is based on a multilevel queue structure 19 20

Memory Management

• Memory model is straightforward • Fundamental concepts • Goal – Address space with 3 segments – Programs should be portable • Text segment – only • Data segment – System may run on machines with widely – Initialized and unitialized data (BSS) differing memory management units • Stack segment • Has barely changed in decades • Works really well and has not needed much revision

21 22

Handling Memory Sharing Files

Process A Process B Two processes can share a mapped .

• Process A' • Physical memory • Process B's virtual address space A new file mapped simultaneously into two processes 23 24

4 Paging in UNIX UNIX I/O (2)

The core map in 4BSD.

The core map has an entry for each The UNIX I/O system in BSD 25 26

Streams The UNIX (2)

• Before linking. • After linking.

An example of in System (a) Before linking. (b) After linking 27 28

The (3) UNIX File System (1)

• Separate file systems • After mounting

Disk layout in classical UNIX systems (a) (b) (a) Before mounting. (b) After mounting 29 30

5 UNIX File System (2) UNIX File System (3)

Directory entry fields.

The relation between the table, the Structure of the i-node file description 31 32

UNIX File System (4) (1)

• A BSD with three files • The same directory after the file voluminous has • Examples of remote mounted file systems been removed • Directories are shown as squares, files as circles 33 34

Network File System (2) Security in UNIX

The NFS layer structure.

The NFS layer structure Some examples of file protection modes

35 36

6