Chapter 1 Introduction 1 1 What is an

  • Slides: 51
Download presentation
Chapter 1 Introduction 1. 1 What is an operating system 1. 2 History of

Chapter 1 Introduction 1. 1 What is an operating system 1. 2 History of operating systems 1. 3 The operating system zoo 1. 4 Computer hardware review 1. 5 Operating system concepts 1. 6 System calls 1. 7 Operating system structure 1

Introduction • A computer system consists of – hardware – system programs – application

Introduction • A computer system consists of – hardware – system programs – application programs 2

What is an Operating System • It is an extended machine – Hides the

What is an Operating System • It is an extended machine – Hides the messy details which must be performed – Presents user with a virtual machine, easier to use – System calls • It is a resource manager – Each program gets time with the resource – Each program gets space on the resource 3

Resource Manager • Tempo – CPU, impressora, usuarios • Espaco – Disco, memoria

Resource Manager • Tempo – CPU, impressora, usuarios • Espaco – Disco, memoria

History of Operating Systems (1) Early batch system – bring cards to 1401 –

History of Operating Systems (1) Early batch system – bring cards to 1401 – read cards to tape – put tape on 7094 which does computing – put tape on 1401 which prints output 5

History of Operating Systems (2) • First generation 1945 - 1955 – vacuum tubes,

History of Operating Systems (2) • First generation 1945 - 1955 – vacuum tubes, plug boards • Second generation 1955 - 1965 – transistors, batch systems • Third generation 1965 – 1980 – ICs and multiprogramming • Fourth generation 1980 – present – personal computers 6

2 nd geration • Structure of a typical Fortran. Monitor. System job – 7

2 nd geration • Structure of a typical Fortran. Monitor. System job – 7 2 nd generation; desperdicio de CPU

3 rd generation • Multiprogramming system, many jobs in memory 8

3 rd generation • Multiprogramming system, many jobs in memory 8

4 th generation • Personal computers • Graphical user interface: Windows • Minix (microkernel)

4 th generation • Personal computers • Graphical user interface: Windows • Minix (microkernel) → Linux (monolitco, GNU, X-windows) 9

The Operating System Zoo • • Mainframe operating systems Server operating systems Multiprocessor operating

The Operating System Zoo • • Mainframe operating systems Server operating systems Multiprocessor operating systems Personal computer operating systems Real-time operating systems Embedded operating systems Smart card operating systems

Computer Hardware Review (1) Monitor Bus • Components of a simple personal computer 1

Computer Hardware Review (1) Monitor Bus • Components of a simple personal computer 1

1) Processador ciclo de busca, execucao registradores: PC, SP, PSW (CPSR) modo kernel/user; kernel

1) Processador ciclo de busca, execucao registradores: PC, SP, PSW (CPSR) modo kernel/user; kernel = supervisor TRAP pipeline (RISC), varias unidades de execucao

Computer Hardware Review (2) (a) A three-stage pipeline (b) A superscalar CPU 1

Computer Hardware Review (2) (a) A three-stage pipeline (b) A superscalar CPU 1

2) Memoria memoria volatil x nao volatil multiprogramacao: Varios processos na memoria Como obter

2) Memoria memoria volatil x nao volatil multiprogramacao: Varios processos na memoria Como obter memoria grande e barata? Como proteger os processos uns dos outros? Como tratar a realocacao do codigo?

Typical memory hierarchy numbers shown are rough approximations 1

Typical memory hierarchy numbers shown are rough approximations 1

Hierarquia de memoria Cache: quando coloca e remove dado no cache? Chaveamento de processo

Hierarquia de memoria Cache: quando coloca e remove dado no cache? Chaveamento de processo e cache miss.

Structure of a disk drive 1

Structure of a disk drive 1

Protecao e realocacao de codigo One base-limit pair and two base-limit pairs b) codigo

Protecao e realocacao de codigo One base-limit pair and two base-limit pairs b) codigo compartilhado 1

Protecao e realocacao de codigo MMU - Memory Management Unit Ao chavear processos, cache

Protecao e realocacao de codigo MMU - Memory Management Unit Ao chavear processos, cache vira lixo

3) Dispositivos de Entrada/Saida HW: controladora, dispositivo controladora: acesso via portas pode ser complexo

3) Dispositivos de Entrada/Saida HW: controladora, dispositivo controladora: acesso via portas pode ser complexo (calcular onde estah setor do disco) interface padronizada: ex: IDE SW: Drivers fabricante ou engenharia reversa instalacao: kernel ou modulo

I/O é lerdo Como a CPU pode trabalhar enquanto I/O nao fez leitura ou

I/O é lerdo Como a CPU pode trabalhar enquanto I/O nao fez leitura ou escrita?

Interrupcao (a) (b) (a) Steps in starting an I/O device and getting interrupt (b)

Interrupcao (a) (b) (a) Steps in starting an I/O device and getting interrupt (b) How the CPU is interrupted 2

Interrupcao, exemplo 1. CPU programa controladora de disco para leitura 2. Disk controller avisa

Interrupcao, exemplo 1. CPU programa controladora de disco para leitura 2. Disk controller avisa dados lidos 3. interrupcao (alguem interrompeu). 4. mostra quem interrompeu

Vetor de interrupcao ARM

Vetor de interrupcao ARM

Computer Hardware Review (7) Structure of a large Pentium system

Computer Hardware Review (7) Structure of a large Pentium system

Processes. Program in execution. Address space: code, data, stack. Process table: – list of

Processes. Program in execution. Address space: code, data, stack. Process table: – list of open files, state, UID . Communication – sinais (divisao por zero), mensagens . scheduling

Processes • A process tree (fork, exec, wait; UID, GID) – A created two

Processes • A process tree (fork, exec, wait; UID, GID) – A created two child processes, B and C – B created three child processes, D, E, and 2

Processes (a) A potential deadlock. (b) an actual deadlock. 2

Processes (a) A potential deadlock. (b) an actual deadlock. 2

Main memory Holds executing programs Multiple programs - protection Large programs - virtual memory

Main memory Holds executing programs Multiple programs - protection Large programs - virtual memory system calls para compartilhar memoria, mapear arquivos em memoria. 2

File Systems File system for a university department 3

File Systems File system for a university department 3

Files. Abstract model of device independent files. Hierarchy, directories, operations. Absolute, relative paths; .

Files. Abstract model of device independent files. Hierarchy, directories, operations. Absolute, relative paths; . root and working direcotry. special files (I/O devices): block, character. security (rwx, ) 3

Operating System Concepts (4) • Before mounting, – files on floppy are inaccessible •

Operating System Concepts (4) • Before mounting, – files on floppy are inaccessible • After mounting floppy on b, – files on floppy are part of file hierarchy 3

Operating System Concepts (5) Two processes connected by a pipe 3

Operating System Concepts (5) Two processes connected by a pipe 3

Steps in Making a System Call There are 11 steps in making the system

Steps in Making a System Call There are 11 steps in making the system call read (fd, buffer, nbytes) 3

System calls. interface user process to kernel. machine dependant, but in procedure libraries (POSIX)

System calls. interface user process to kernel. machine dependant, but in procedure libraries (POSIX) 3

Some System Calls For Process Management pid = fork() pid = waitpid(pid, &statlock, opts)

Some System Calls For Process Management pid = fork() pid = waitpid(pid, &statlock, opts) s = wait(&status) s = execve(name, arg, envp) exit(status) pid = getpid()

Signals s=sigaction(sig, &act, &oldact) s=sigreturn(&context) s = sigpending(set) s = sigsuspend(sigmask) s = kill(pid,

Signals s=sigaction(sig, &act, &oldact) s=sigreturn(&context) s = sigpending(set) s = sigsuspend(sigmask) s = kill(pid, sig) residual = alarm(seconds) s = pause()

Some System Calls For File Management 3

Some System Calls For File Management 3

Some System Calls For Directory Management 3

Some System Calls For Directory Management 3

Some System Calls For Miscellaneous Tasks s = chdir(dirname) s = chmod(name, mode) s

Some System Calls For Miscellaneous Tasks s = chdir(dirname) s = chmod(name, mode) s = kill(pid, signal) seconds = time(&seconds) 4

System Calls (1) • A stripped down shell: while (TRUE) { /* repeat forever

System Calls (1) • A stripped down shell: while (TRUE) { /* repeat forever */ type_prompt( ); /* display prompt */ read_command (command, parameters) /* input from terminal */ if (fork() != 0) { /* fork off child process */ /* Parent code */ waitpid( -1, &status, 0); /* wait for child to exit */ } else { /* Child code */ execve (command, parameters, 0); /* execute command */ } } 4

System Calls (2) • Processes have three segments: text, data, stack 4

System Calls (2) • Processes have three segments: text, data, stack 4

System Calls (3) (a) Two directories before linking /usr/jim/memo to ast's directory (b) The

System Calls (3) (a) Two directories before linking /usr/jim/memo to ast's directory (b) The same directories after linking 4

System Calls (4) (a) File system before the mount (b) File system after the

System Calls (4) (a) File system before the mount (b) File system after the mount 4

System Calls (5) Some Win 32 API calls 4

System Calls (5) Some Win 32 API calls 4

Operating System Structure (1) Simple structuring model for a monolithic system 4

Operating System Structure (1) Simple structuring model for a monolithic system 4

Operating System Structure (2) Structure of the THE operating system – – camadas bem

Operating System Structure (2) Structure of the THE operating system – – camadas bem delimitadas, Multix - aneis concentricos - traps entre as camadas 4

Operating System Structure (3) Structure of VM/370 with CMS – – CMS - Conversational

Operating System Structure (3) Structure of VM/370 with CMS – – CMS - Conversational Monitor System VM: Virtual Machine Monitor • • MS-DOS / Pentium JVM 4

Operating System Structure (4) The client-server model microkernel mecanismo x politica MINIX 4

Operating System Structure (4) The client-server model microkernel mecanismo x politica MINIX 4

Microkernel x monolitico - Por que microkernel é bom? • Tanenbaum: codigo limpo -

Microkernel x monolitico - Por que microkernel é bom? • Tanenbaum: codigo limpo - Por que microkernel é ruim? • • Linus Torvalds: perfomance sofrivel. Experiencia pessoal

Loop infinito em drivers - Driver estah no kernel, normalmente - Caso Minix 3.

Loop infinito em drivers - Driver estah no kernel, normalmente - Caso Minix 3. 1; recuperacao de drivers. - problema de deadlock na recuperacao de drivers.