introduction to operating systems part itddd63/info/slides/tddd63_fo6_1sl.pdfc. kessler, ida,...

47
Copyright Notice: The slides partly use material from Silberschatz’s, Galvin’s and Gagne’s book (“Operating System Concepts”, course book in TDDB68). No part of the lecture notes may be reproduced in any form, due to the copyrights reserved by Wiley. These lecture notes should only be used for internal teaching purposes at the Linköping University. Christoph Kessler, IDA, Linköpings universitet. Introduction to Operating Systems Part I Christoph Kessler IDA, Linköping University TDDD63

Upload: others

Post on 16-Mar-2020

10 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

Copyright Notice: The slides partly use material from Silberschatz’s, Galvin’s and Gagne’s book (“Operating System Concepts”, course book in TDDB68). No part of the lecture notes may be reproduced in any form, due to the copyrights reserved by Wiley. These lecture notes should only be used for internal teaching purposes at the Linköping University.

Christoph Kessler, IDA, Linköpings universitet.

Introduction to Operating Systems

Part I

Christoph KesslerIDA, Linköping University

TDDD63

Page 2: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

2C. Kessler, IDA, Linköpings universitet.

Why should I be interested in Operating Systems?

IBM 360

DEC-20

Sun Workstations

IBM PC

Mainframe

Midframe

Linux

WindowsMS-DOS

MacOSX

Unix

OS/360

TOPS-10

MiniComputers

Workstations

?

Page 3: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

3C. Kessler, IDA, Linköpings universitet.

A Whole New World!Smart Phones Portability

ConnectivityNetworksSensors

Wearable Devices

Page 4: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

4C. Kessler, IDA, Linköpings universitet.

A Whole New Future World!Smart Vehicles Smart Highways

Smart Cities Smart Homes / Smart El-Grids

The current 7-Series BMW and S-class Mercedes boast about 100 processors apiece.

A relatively low-profile Volvo still has 50 to 60 baby processors on board.

Page 5: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

5C. Kessler, IDA, Linköpings universitet.

Increase in Hardware ComplexityNeed for new types of interfacing to hardware• Multiprocessor servers• Hardware multithreading• Multicore CPUs• Many-Core CPUs• Accelerators e.g. GPGPU• Hybrid computing• Clusters• Cloud servers• …

NSC’s cluster supercomputer “Triolith” (TDDC78)

Nvidia Tesla GPU

“Moore’s Law”(prediction 1965):#Transistors / mm2

doubles every ~2 years.Still holds today!

Source: Intel

Page 6: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

6C. Kessler, IDA, Linköpings universitet.

Increase in Software Complexity

Need for new types of OS ArchitecturesMacOS X 10.4: 86M LOC (2005)

Linux kernel 2015

Linux kernel 2001

Page 7: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

7C. Kessler, IDA, Linköpings universitet.

AgendaLecture I:n Computer Systems Overviewn Building and Executing Programsn Operating System Basics

Lecture II:n Interrupts and I/On System Callsn CPU Managementn Memory Managementn File Systemn Protection and Security

Page 8: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

Copyright Notice: The slides partly use material from Silberschatz’s, Galvin’s and Gagne’s book (“Operating System Concepts”, course book in TDDB68). No part of the lecture notes may be reproduced in any form, due to the copyrights reserved by Wiley. These lecture notes should only be used for internal teaching purposes at the Linköping University.

Christoph Kessler, IDA, Linköpings universitet.

Computer Systems

Overview

Page 9: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

9C. Kessler, IDA, Linköpings universitet.

Computer Systems and Environmentsn Stand-alone desktop computern Client-server systemsn Parallel systemsn Clustered systemsn Distributed systemsn Real-time systemsn Handheld systems

Page 10: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

10C. Kessler, IDA, Linköpings universitet.

Stand-alone desktop computer

n PC, workstation: Computer system dedicated mainly to a single user. l I/O devices: keyboards, mice, screens, small printers.

l Requirement: User convenience and responsiveness.

l Can adopt technology developed for larger operating system

n May run several different types of operating systems (Windows, MacOS, UNIX, Linux)

Page 11: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

11C. Kessler, IDA, Linköpings universitet.

Client-Server Computingn Servers respond to requests by clientsl Remote procedure call –

also across machine boundaries via networkn Client/Server are mainly software roles,

but machines can be dedicated to one or few such roles, e.g.l Compute server:

compute an action requested by the clientl File server:

Interface to file system (read, create, update, delete)

Page 12: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

12C. Kessler, IDA, Linköpings universitet.

Parallel Systems (1)n Multiprocessor systems with more than one CPU in close communication.

l Today the default, even for desktop machines (multi-core)

n Tightly coupled system (aka. shared-memory system, multiprocessor)l processors share memory and a clock; l communication usually takes place through the shared memory.

n Advantages of parallel systems: l Increased throughputl Economical

4Scalability of performance 4Multiprocessor system vs multiple single-processor system

(reduction of hardware such as disks, controllers etc)l Increased reliability

4graceful degradation (fault tolerance, …)4 fail-soft systems (replication, …)

Page 13: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

13C. Kessler, IDA, Linköpings universitet.

Parallel Systems (2)

n Symmetric multiprocessing (SMP)l Each processor runs an identical copy of the operating system.l Many processes can run at once without performance deterioration.l Most modern operating systems support SMP

n Asymmetric multiprocessingl Each processor is assigned a specific task;

a master processor schedules and allocates work to slave processors.l More common in special-purpose systems (e.g., embedded MP-SoC)

Remark: the notion of “processor” is relative: A traditional PC is normally considered to only have one CPU, but it usually has a graphics processor, a communication processor etc, and this is not considered a multi-processing system.

SMP architecture

Page 14: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

14C. Kessler, IDA, Linköpings universitet.

Hardware Multithreading,Multi-Core

P0 P1L1$ D1$ L1$ D1$

L2$

Memory Ctrl

Intel XeonDualcore(2005)

Main memory

P0 P1L1$ D1$ L1$ D1$

L2$

Memory Ctrl

Intel XeonDualcore(2005)

Main memory

2 hardware threads per core

2 cores per CPU chip

à Appears to the OSlike 4 standard processors

Page 15: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

15C. Kessler, IDA, Linköpings universitet.

Parallel Systems (3)n Speed-up of a single application by parallel processing?

l Requires parallelisation / restructuring of the programl Or explicitly parallel algorithmsl Used in High-Performance Computing for numerically intensive

applications (weather forecast, simulations, ...)l Now ubiquitous problem due to switch to multicore/manycore CPUs

n Multicomputer(”distributed memory parallel computer”) l loosely coupledl can be a more economic and scalable

alternative to SMP’sl but more cumbersome to program

(message passing)l Example: ”Beowulf ” Clusters

[ More in TDDC78 – Programming parallel computersNSC Triolith

Page 16: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

16C. Kessler, IDA, Linköpings universitet.

Parallel Computing Systems

Page 17: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

17C. Kessler, IDA, Linköpings universitet.

Clustered Systemsn Like multiprocessor systems,

but multiple systems (servers) working togetherl Often using a high-speed interconnect

between servers (e.g. Infiniband)l Usually sharing external mass storage

via a storage-area network (SAN)n Provides a high-availability/reliability service which survives failuresl Asymmetric clustering - one server runs the application while other

servers are in hot-standby model Symmetric clustering - has multiple nodes running the same

application, monitoring each othern Some clusters are used for high-performance computing (HPC)l Applications must be written to use parallelization

4 HPC clusters: MPI (Message-Passing Interface) à TDDC784 Data centers: Mapreduce / Hadoop

NSC Triolith

Page 18: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

18C. Kessler, IDA, Linköpings universitet.

Distributed Systems (1)n Loosely coupled systeml each processor has its own local memoryl processors communicate with one another through various

communications lines, such as high-speed buses or telephone lines (LAN, WAN, MAN, Bluetooth, …).

n Distribute the computation among several physical processors.n Advantages of distributed systems:l Resource sharing l Computation speed up l Adaptivity: load sharing (migration of jobs)l Fault tolerance

n May be either client-server or peer-to-peer systems

Page 19: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

19C. Kessler, IDA, Linköpings universitet.

Distributed Systems (2)n Network Operating Systeml provides file sharing, e.g., NFS - Network File Systeml provides communication schemel runs independently from other computers on the network

n Distributed Operating Systeml less autonomy between computersl gives the impression that there is a single operating

system controlling the network.

[ More about this in TDDD25 Distributed Systems

Page 20: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

20C. Kessler, IDA, Linköpings universitet.

Distributed Computing Systems

Page 21: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

21C. Kessler, IDA, Linköpings universitet.

Real-Time Systemsn Often used as a control device in a dedicated application such as

controlling scientific experiments, medical imaging systems, industrial control systems, and some display systems.

n Well-defined tasks with fixed time constraints.

n Hard real-time systems.l Conflicts with time-sharing systems,

not supported by general-purpose OSs.

n Soft real-time systemsl Limited utility in industrial control or roboticsl Useful in applications (multimedia, virtual

reality) requiring advanced OS features.

[ More in TDDD07 Real-time Systems

Page 22: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

22C. Kessler, IDA, Linköpings universitet.

Handheld Systemsn Personal Digital Assistants (PDAs), iPADs etc. n Cellular telephonesn Issues:l Limited memoryl Slow processorsl Small display screensl Limited battery lifetime

Shipping with 2GB-4GB RAM?Iphone 5S

1.5-1.9GHz

Page 23: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

Copyright Notice: The slides partly use material from Silberschatz’s, Galvin’s and Gagne’s book (“Operating System Concepts”, course book in TDDB68). No part of the lecture notes may be reproduced in any form, due to the copyrights reserved by Wiley. These lecture notes should only be used for internal teaching purposes at the Linköping University.

Christoph Kessler, IDA, Linköpings universitet.

Before talking about Operating Systems…

Page 24: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

24C. Kessler, IDA, Linköpings universitet.

Before talking about OS, …n … a short note on programming languages

suitable for system programming

n Early operating systems were implemented in assembly language (and some low-level parts of modern OS still are).l Necessary for direct access to hardware devices

n Since the 1970s the dominating language for system programming is C.l Also used a lot in high-performance and embedded computing l Today, no new microprocessor ships without a C compiler.l Many “high-level” programming languages are compiled to C.

n You will need C for programming labs in later courses l Operating systems, Compiler construction, Parallel programming,

Multicore/GPU programming, Realtime systems, Embedded systems, …

Page 25: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

25C. Kessler, IDA, Linköpings universitet.

Java

n For application programming onlyn Design goals:

l Programmer productivityl Safetyl Hardware completely hidden

n Comfortablel E.g. automatic memory

managementn Protection (to some degree)

l E.g., array bound checkingn Slow n Time-unpredictable

Java vs. CC

n For system programming mainlyn Design goals:

l Direct control of hardwarel High performance / real-timel Minimalistic design

n Less comfortablen Little protectionn ”low-level”

Page 26: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

26C. Kessler, IDA, Linköpings universitet.

A Short History of Cn C was developed in the early 1970’s by Dennis Ritchie at Bell Labs

l Objective: structured but flexible programming languagee.g. for writing device drivers or operating systems

l Used for implementing the Unix OSl Book 1978 by Brian Kernighan and Dennis Ritchie (”K&R-C”)

n ”ANSI-C” 1989 standard by ANSI (”C89”)l The C standard for many programmers (and compilers...)l Became the basis for standard C++l Java borrowed much of its syntaxl The GNU C compiler implemented a superset (”GNU-C”)

n ”C99” standard by ISO, only minor changesn ”C11” (ISO) – multithreading support addedn …

Page 27: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

Copyright Notice: The slides partly use material from Silberschatz’s, Galvin’s and Gagne’s book (“Operating System Concepts”, course book in TDDB68). No part of the lecture notes may be reproduced in any form, due to the copyrights reserved by Wiley. These lecture notes should only be used for internal teaching purposes at the Linköping University.

Christoph Kessler, IDA, Linköpings universitet.

How to build and execute programs on a real computer

Page 28: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

28C. Kessler, IDA, Linköpings universitet.

The Compilation Workflow

/* file hello.c */

#include <stdio.h>

int main() {

printf("hello, world\n");}

.file "hello.c"

.section .rodata.str1.1,"aMS",@progbits,1.LC0:

.string "hello, world"

.text

.p2align 4,,15.globl main

.type main, @functionmain:

pushl%ebpmovl %esp, %ebpsubl $8, %espandl $-16, %espsubl $16, %espmovl $.LC0, (%esp)call putsleavexorl %eax, %eaxretsize

Page 29: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

29C. Kessler, IDA, Linköpings universitet.

Preprocessing Phase

C Preprocessor (cpp): modifies the original C source programaccording to directives that begin with the # character.

#include <stdio.h> tells the processor to read the contents of the systemheader file stdio.h and insert it directly into the program text.

Output is another C source program, typically with the .i suffix.

Page 30: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

30C. Kessler, IDA, Linköpings universitet.

Compilation Phase

Compilation Phase (cc1): Translate the text file hello.i into the text file hello.s.hello.s contains an assembly-language program

Each statement in an assembly language program exactly describesone low-level machine language instruction in a standard text form.

main:pushl %ebpmovl %esp, %ebpsubl $8, %espandl $-16, %espsubl $16, %espmovl $.LC0, (%esp)call putsleavexorl %eax, %eaxret

Assembly languageprovides a commonoutput language for different compilers

C compiler

Assemblylanguage

Fortran compiler

Page 31: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

31C. Kessler, IDA, Linköpings universitet.

hello.s (in x86 assembler language)

.file "hello.c"

.section .rodata.str1.1,"aMS",@progbits,1.LC0:

.string "hello, world"

.text

.p2align 4,,15.globl main

.type main, @functionmain:

pushl %ebpmovl %esp, %ebpsubl $8, %espandl $-16, %espsubl $16, %espmovl $.LC0, (%esp)call putsleavexorl%eax, %eaxret.size main, .-main.section .note.GNU-stack,"",@progbits.ident "GCC: (GNU) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)"

Page 32: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

32C. Kessler, IDA, Linköpings universitet.

Assembly Phase

Assembler (as): translates the text-based assembly program into machine language instructions,packages them in a form known as a relocatable objectprogram, and stores the result in the object file hello.o

hello.o is a binary file (object file) whose bytes encode machine instructions and -data rather than characters. Binary files use a system-specific binary file format, e.g. ELF, COFF.

a4 f0 dd 077c 65 a6 b206 0f c3 dda2 ff bd 87…

Page 33: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

33C. Kessler, IDA, Linköpings universitet.

Linking Phase

Linker (ld): merges pre-compiled object files to a single one. The result is an executable object file that is ready to be

loaded into memory (using the OS loader)and executed by the system.

The hello program uses the printf function, which is part of the standard C library. This function resides in a separate precompiled object file (e.g. printf.o or in libc.a) that has to be merged with hello.o.Also some additional code and data (program startup code, C runtimesystem, etc., in libc.a) is added by the linker.

Page 34: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

34C. Kessler, IDA, Linköpings universitet.

Calling the entire toolchain

E.g., gcc hello.c –o hello(here, for the GNU C compiler gcc)calls cpp, cc1, as, ld for single-module program hello.c

For automatizing the build process of multi-module programs, building-tools like make or IDEs like ECLIPSE are convenient.

Page 35: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

35C. Kessler, IDA, Linköpings universitet.

Compiling and Linkingfor Multi-Module C Programs

glob.hxy.h

mymain.c def.cabc.c

stdio.h

#include

preprocess

#include#include

abc.o mymain.o def.o

compile + asm

a.out (executable)

link libc.a

C run-time library is linked with the user code

Page 36: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

36C. Kessler, IDA, Linköpings universitet.

Running an Executable Program

/* hello.c */#include <stdio.h>

int main() {

printf("hello, world\n");}

hello Executable Object File(binary)

unix> ./hello

hello, world

unix>

In a Unix system, a shell is an application program which is a command line interpreter

The shell prints a prompt, waits for the user to type in a command and then performs the command.

If it is not a built-in shell command, then the shell assumes it is an executable file and that it should load and run it.

Input

OutputPreprocessCompileAssembleLink

Page 37: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

37C. Kessler, IDA, Linköpings universitet.

Running the hello Program

Reading the hello command from the keyboard

As the characters ./hello are typedat the keyboard, the shell programreads each one into a register andthen it is stored in memory

Page 38: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

38C. Kessler, IDA, Linköpings universitet.

Running the hello program

Loading the executable from disk into main memory

When the enter key is hit on thekeyboard, the shell knows that we have finished typing the command.

The shell then calls the OS to allocate memory and load the executable file.The loader copies the codeand data in the hello object filefrom disk to main memory.

Using a technique called Direct Memory Access (DMA)the data travels directly from thedisk to the main memory withoutpassing through the processor.

Page 39: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

39C. Kessler, IDA, Linköpings universitet.

Running the hello program

Writing the output string from memory to the display

Once the code and data in the hello object file are loaded into memory, the processor begins executing the machine instructions in the hello program’s main routine

main:pushl %ebpmovl %esp, %ebpsubl $8, %espandl $-16, %espsubl $16, %espmovl $.LC0, (%esp)call putsleavexorl %eax, %eaxret

These instructions copy the bytesin the “hello, world” string frommemory to the register fileand from there to the display device where they are displayed on the screen

Page 40: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

Copyright Notice: The slides partly use material from Silberschatz’s, Galvin’s and Gagne’s book (“Operating System Concepts”, course book in TDDB68). No part of the lecture notes may be reproduced in any form, due to the copyrights reserved by Wiley. These lecture notes should only be used for internal teaching purposes at the Linköping University.

Christoph Kessler, IDA, Linköpings universitet.

OS Basics

Page 41: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

41C. Kessler, IDA, Linköpings universitet.

What is an Operating System (OS)?

n A program that acts as an intermediarybetween a user of a computer and the computer hardware.

n Operating system goals:l Execute user programs in a well-defined environment.l Make application software portable and not tied to a specific machine

4 hiding low-level and implementational detaill Make the computer system convenient to use.l Administrate system resources.l Improves overall system reliability

4 error confinement, fault tolerance, reconfiguration...l Enable efficient use of the computer hardware

4 support parallel activity, avoid wasted CPU cycles...l Provides protection mechanisms for user programs and files

and security against possible threats from within and outside the system

Page 42: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

42C. Kessler, IDA, Linköpings universitet.

What is an Operating System (OS)?

n An operating system provides an environmentwithin which other programs can do useful work; the OS does not perform any “useful” function itself.

Page 43: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

43C. Kessler, IDA, Linköpings universitet.

1%

99%

General purpose systems Embedded systems

Microprocessor market shares in 1999

Where are OSs found?

Page 44: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

44C. Kessler, IDA, Linköpings universitet.

Operating Systems (A Selection)General purpose operating systemsn Unix

l incl. variants, such as Sun/Oracle Solaris, HP-UXn Linuxn Windows 95/98/2000, NT/XP/Vista/7/8/10/…n Mac OS Xn …

Application specific operating systems, e.g. mobile OS, real-time OSn Androidn iOSn Symbiann Windows CE, Mobile, Phonen Embedded Linuxn RT-Linuxn VxWorksn OSEn QNXn ...

Page 45: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

45C. Kessler, IDA, Linköpings universitet.

Operating System Definition

n OS is a resource allocatorl Manages all resources of a computer systeml Decides between conflicting requests

for efficient and fair resource usen OS is a control programl Controls execution of programs

to prevent errors and improper use of the computern No universally accepted definitionn “The one program running at all times on the computer”

is called the kernel. Everything else is either a system program (ships with the operating system) or an application program.

Page 46: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

46C. Kessler, IDA, Linköpings universitet.

Computer System Structure

Computer systemcan be divided into 4 components:

n Hardwareprovides basic computing resourcesl CPU, memory, I/O devices

n Operating systemcontrols and coordinates use of hardware among various applications and users

n Application programsdefine the ways in which the system resources are used to solve the computing problems of the usersl Word processors, compilers, web browsers, database systems, games

n Usersl People, machines, other computers

Page 47: Introduction to Operating Systems Part ITDDD63/info/slides/TDDD63_Fo6_1sl.pdfC. Kessler, IDA, Linköpings universitet. 12 Parallel Systems (1) n Multiprocessor systems with more than

47C. Kessler, IDA, Linköpings universitet.

AgendaLecture I:n Computer Systems Overviewn Building and Executing Programsn Operating System Basics

Lecture II:n Interrupts and I/On System Callsn CPU Managementn Memory Managementn File Systemn Protection and Security