CS162 Lecture1 --Operating System Overview

汇总

硬件基础

  • BIOS:Basic Input Output System
  • PC(program counter) SP(stack pointer)
  • CS:IP code segment : instruction pointer.
  • .s source code files written in assembly

Overview

Compare of cs61c and cs162

  • Processor – Thread
  • Memory – Address Space
  • Disks,SSDS,… – Files
  • Networks – Sockets
  • Machines – Processes

Instruction Fetch/Decode/Execute
在这里插入图片描述

Four fundamental OS concepts

  • Thread: Single unique execution context(Fully desribes program state)
  • Address space: set of memory address accessible to program(r/o)
  • Process: an instance of a running program(protected address space+ >=1 threads)
  • Dual Mode operation/Protection(only the “system” has the ability to access certain resources)

主课

Thread

Concept
  • 3 states
    • running
    • ready – eligible to run, but not currently running
    • blocked – ineligible to run (e.g.waiting for an I/O to finish)
  • Concurrency vs parallelism
    • Concurrency is about handling multiple things at once
    • Parallelism is about doing multiple things simultaneously
    • Parallel => concurrent, but not the other way round!

Networked servers must handle concurrent requests

Parallel programs must parallelise for performance

Concurrency
  • run two threads concurrently

    • Scheduler is free to run threads in any order and interleaving
    • Thread may run to completion or time-slice in big chunks or small chunks
  • Multiprocessing vs multithreading

    • Multiprocessing: Multiple CPUs(cores)
    • Multithreading: Multiple threads/processes

20210317164857
20210317165234

Address Space

Simple Address translation with base and bound
在这里插入图片描述

Process

Thread encapsulate concurrency

Address spaces encapsulate protection
在这里插入图片描述

Interrupt

Example:web server
20210317172017

UNIX process management
  • fork – system call to create a copy of the current process, and start it running

    • No arguments!
  • exec – system call to change the program being run by the current process

    • example: shell程序先copy原有shell然后清除
  • wait – system call to wait for a process to finish

  • signal – system call to send a notification to another process

Dual Mode Operation

Unix structure
在这里插入图片描述
3 types of user → \rightarrow kernel mode transfer

  • syscall
    • process requests a system service,e.g.,exit()
    • like a function call, but “outside” the process
  • interrupt
    • external asychronous event triggers context switch
    • e.g.,timer, I/O device
  • trap/exception
    • internal asychronous event in process triggers context switch
    • e.g.,protection violation(segment fault),divide by zero
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值