Top Banner
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences between implementations. Will use programming to enhance our understanding of basic concepts.
38

We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Jan 29, 2016

Download

Documents

Gwenda Poole
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X.

Will discuss differences between implementations.

Will use programming to enhance our understanding of basic concepts.

Page 2: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Today’s Topics

High level view of Operating System Interrupts Context Switches Multiprogramming Timesharing Protection of system resources.

Page 3: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Components of a Computer System

System and Application Programs Operating System Hardware (CPU, memory, I/O

devices).

System and application Programs

User User User User

Web Browsing Text Editor Database Compiler

Operating System

Hardware

Page 4: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Components of a Computer System

System and Application Programs Operating System Hardware (CPU, memory, I/O

devices)

System and application Programs

App1 App2 App3 App4

Web Browsing Text Editor Database iTunes

Operating System

Hardware

Page 5: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

System programs make our lives easier but are not part of the Operating System.

Compilers, editors, linkers, loaders, shells……. Operating System performs two functions:

Allocates, schedules, manages, and protects system resources.

Provides a convenient interface to system resources. Don’t want to have to write device driver to store files

on disk.

Page 6: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Interrupts

Operating systems are interrupt-driven. Perform action, such as giving control of the CPU to

an application, then does not regain control of CPU until an interrupt occurs.

Page 7: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

CPU and other devices can run concurrently. Can start I/O operation and start application

executing. When requested operation completed, device

generates hardware interrupt. User programs generate interrupts when

making system calls (requesting service from OS)

TRAP instruction. Generally termed software interrupt.

Page 8: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Interrupts

When an interrupt is generated, the CPU stops what it is doing and execution is transferred to the appropriate interrupt handler.

Addresses of interrupt handlers are found in the interrupt vector.

Table of addresses Each device (and TRAP) has a particular offset within

the table

Page 9: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

100

500

800

1500

Interrupt Vector

0

1

2

3

0 I/O Device 1

1 I/O Device 2

2 NIC

3 TRAP

Page 10: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Interrupts

Consider some Joe_Program (nickname is JP or Joe) executing and a device issues an interrupt.

Need to jump to interrupt handler, but ……

Page 11: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Interrupts

Consider some Joe_Program executing and a device issues an interrupt.

Need to jump to interrupt handler, but …… What do we do with Joe?

Page 12: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Interrupts

Consider some Joe_Program executing and a device issues an interrupt.

Need to jump to interrupt handler, but …… What do we do with Joe?

What is the minimal information to save to be able to restart his execution?

Page 13: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Interrupts

Consider some Joe_Program executing and a device issues an interrupt.

What do we do with Joe? What is the minimal information to save to be able to

restart his execution? Address of the next instruction.

Page 14: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

What if interrupt processing routine needs to use all of the CPU registers?

Page 15: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

What if interrupt processing routine needs to use all of the CPU registers?

Better save a copy of the state of all of the registers PJ is using.

Page 16: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Once interrupt routine completed, how do we get JP restarted?

Page 17: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Once interrupt routine completed, how do we get JP restarted?

Restore state of registers Set the Instruction Pointer to the next instruction JP

was going to execute. It should appear to JP as if its execution was never

interrupted.

Page 18: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Saving and restoring application state is termed a context switch.

Page 19: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Operating System Structure A key concept of operating systems is

multiprogramming (or multitasking).

Technique developed because CPU and I/O device time were very expensive.

Basic idea: Keep multiple jobs in memory. When one job blocks on I/O, the CPU immediately

switches to another job.

Page 20: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

This keeps CPU and I/O devices fully utilized. Without multiprogramming, CPU would be idle during

I/O operations. First developed for batch systems in the 60s.

No interactions between user and programs.

Page 21: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Multiprogramming Batch SystemsProblem: CPU and I/O very expensive.Solution: Multiplex CPU between multiple jobs.

Page 22: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Time-Sharing Systems–Interactive Computing

Logical extension of multiprogramming. The CPU is multiplexed among several jobs that

are kept in memory and on disk (the CPU is allocated to a job only if the job is in memory).

A job swapped in and out of memory to the disk. Each user is executing a shell program.

Takes user command and executes it. Waits for the next command.

Page 23: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Time-Sharing Systems–Interactive Computing

Goal is to give the illusion that each user has own machine.

Response time is a priority.

Page 24: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Protection of System Resources

I/O Devices Memory CPU Files

Page 25: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Protection of System Resources

Based on dual-mode execution: kernel mode and user mode. Privileged instructions can be issued only in kernel mode. Mode bit in PSW, checked on every instruction.

Page 26: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

User process executing System Call

Trap, mode bit = 0 Execute System Call

Return. Mode bit = 1

Continue Execution

Mode

Bit=1

Page 27: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Protection of I/O Devices

All I/O instructions are privileged instructions. Only accessed through system calls.

Page 28: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Memory Protection

Must provide memory protection for the interrupt vector, interrupt service routines, and other applications address space.

Two registers that determine the range of legal addresses a program may access: Base register – holds the smallest legal

physical memory address. Limit register – contains the size of the

range Memory outside the defined range is

protected.

Page 29: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Use of A Base and Limit Register

Page 30: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Hardware Address Protection

Page 31: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

CPU (and OS) Protection

Keep user from monopolizing CPU. Ensure OS regains control of CPU.

Page 32: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

CPU Protection

Timer – interrupts computer after specified period to ensure operating system maintains control.

Timer is decremented every clock tick. When timer reaches the value 0, an interrupt occurs.

Timer commonly used to implement time sharing.

Page 33: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Privileged Instructions

Load base and limit registers?

Page 34: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Privileged Instructions

Load base and limit registers? Set the system timer?

Page 35: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Privileged Instructions

Load base and limit registers? Set the system timer? Read the system clock?

Page 36: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Privileged Instructions

Set the system timer? Read the system clock? Load base and limit registers? Open a file?

Page 37: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Privileged Instructions

Load base and limit registers? Set the system timer? Read the system clock? Open a file? Compile a program and create executable?

Page 38: We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.

Privileged Instructions

Load base and limit registers? Set the system timer? Read the system clock? Open a file? Compile a program and create executable? Enable/disable interrupts?