Computer Architecture and OS EECS678 Heechul Yun 1 Administrivia - - PowerPoint PPT Presentation

computer architecture and os
SMART_READER_LITE
LIVE PREVIEW

Computer Architecture and OS EECS678 Heechul Yun 1 Administrivia - - PowerPoint PPT Presentation

Computer Architecture and OS EECS678 Heechul Yun 1 Administrivia Labs start this week Lab homepage http://people.eecs.ku.edu/~frobinso/ 2 Agenda Computer architecture and OS CPU, memory, disk Architecture trends and


slide-1
SLIDE 1

Computer Architecture and OS

EECS678 Heechul Yun

1

slide-2
SLIDE 2

Administrivia

  • Labs start this week
  • Lab homepage

– http://people.eecs.ku.edu/~frobinso/

2

slide-3
SLIDE 3

Agenda

  • Computer architecture and OS

– CPU, memory, disk – Architecture trends and their impact to OS – Architectural support for OS

3

slide-4
SLIDE 4

Recap

  • Batch

– One at a time. CPU is idle while waiting for I/O – Low throughput

  • Multiprogramming

– If a job needs to way for I/O, switch to a new job – Maximize throughput

  • Timesharing

– Switch to next job after some time – Minimize response time

4

slide-5
SLIDE 5

Recap

  • Essential components of a computer

– CPU – Memory – I/O

  • Memory hierarchy
  • Caching

5

slide-6
SLIDE 6

Recap: Memory Hierarchy

6

Fast, Expensive Slow, Inexpensive

slide-7
SLIDE 7

Recap: Caching

  • A very important principle applied in all layers
  • f hardware, OS, and software

– Put frequently accessed data in a small amount of faster memory – Fast, most of the time (hit) – Copy from slower memory to the cache (miss) – Low cost, good performance

7

slide-8
SLIDE 8

Architectural Support for OS

  • Interrupts and exceptions
  • Protected modes (kernel/user modes)
  • Memory protection and virtual memory
  • Synchronization instructions

8

slide-9
SLIDE 9

Interrupt

  • What is an interrupt?

– A signal to the processor telling “do something now!”

  • Hardware interrupts

– Devices (timer, disk, keyboard, …) to CPU

  • Software interrupts (exceptions)

– Divide by zero, special instructions (e.g., int 0x80)

9

slide-10
SLIDE 10

Interrupt Handling

 save CPU states (registers)  execute the associated interrupt service routine (ISR)  restore the CPU states  return to the interrupted program

10

slide-11
SLIDE 11

Timesharing

  • Multiple tasks share the CPU at the same time

– But there is only one CPU (assume single-core) – Want to schedule different task at a regular interval of 10 ms, for example.

  • Timer and OS scheduler tick

– The OS programs a timer to generate an interrupt at every 10 ms.

11

slide-12
SLIDE 12

Dual (User/Kernel) Mode

  • Some operations must be restricted to the OS

– accessing registers in the disk controller – updating memory management unit states – …

  • User/Kernel mode

– Hardware support to distinguish app/kernel – Privileged instructions are only for kernel mode – Applications can enter into kernel mode only via pre-defined system calls

12

slide-13
SLIDE 13

User/Kernel Mode Transition

  • System calls

– Programs ask OS services (privileged) via system calls – Software interrupt. “int <num>” in Intel x86

13

slide-14
SLIDE 14

Memory Protection

  • How to protect memory among apps/kernel?

– Applications shouldn’t be allowed to access kernel’s memory – An app shouldn’t be able to access another app’s memory

14

slide-15
SLIDE 15

Virtual Memory

  • How to overcome memory space limitation?

– Multiple apps must share limited memory space – But they want to use memory as if each has dedicated and big memory space – E.g.,) 1GB physical memory and 10 programs, each

  • f which wants to have a linear 4GB address space

15

slide-16
SLIDE 16

Virtual Memory

16

Process A Process B Process C Physical Memory

MMU

slide-17
SLIDE 17

MMU

  • Hardware unit that translates virtual address to

physical address

– Defines the boundaries of kernel/apps – Enable efficient use of physical memory

17

CPU MMU Memory

Virtual address Physical address

slide-18
SLIDE 18

Synchronization

  • Synchronization problem with threads

18

Thread 1: Deposiit(acc, 10) LOAD R1, account->balance ADD R1, amount STORE R1, account->balance Thread 2: : Deposiit(acc, 10) LOAD R1, account->balance ADD R1, amount STORE R1, account->balance Deposit(account, amount) { { account->balance += amount; }

slide-19
SLIDE 19

Synchronization Instructions

  • Hardware support for synchronization

– TestAndSet, CompareAndSwap instructions – Atomic load and store – Used to implement lock primitives – New TSX instruction  hardware transaction

  • Another methods to implement locks in

single-core systems

– Disabling interrupts

19

slide-20
SLIDE 20

Summary

  • OS needs to understand architecture

– Hardware (CPU, memory, disk) trends and their implications in OS designs

  • Architecture needs to support OS

– Interrupts and timer – User/kernel mode and privileged instructions – MMU – Synchronization instructions

20

slide-21
SLIDE 21

OS Abstractions

Reliable and secure Insecure and unreliable networks File system Mechanical disk Infinite capacity Limited RAM capacity Multiple computers A single computer Abstraction Reality

21

slide-22
SLIDE 22

Acknowledgements

  • Some slides are from

– Authors of the textbook: Abraham Silberschatz, Greg Gagne, and Peter Baer Galvin – Dr. Prasad Kulkarni

22