这是我参与「第五届青训营 」笔记创作活动的第15天 单道程序造成CPU程序空闲,
C1 OS
Processor must wait for I/O instruction to complete before proceeding (a)uniprogramming (b)multiprogarmming when one job needs to wait for i/o,the processor must switch for another job. Programming A Programming B Combined timesharing Multiplie users simultaneously access the system through terminals,so processor is shared among them. Users can interact with each job while it is running.
How does one start an OS?
when a computer boots,it needs to run a first program:bootstrap program Typically in read only memeory The bootstrap program initializes the computer Register content ,device controller contents,etc. It then locates and loads the OS kernel into memory The kernel starts the first process(it called init on Linux) And then,nothing happens until an event occurs
User mode vs kernel mode
Mondern processors support (at least) two execution modes User mode:protected instructions cannot be exexuted(User code) Kernel mode:all instructions can be executed(OS code) mode indicated by a status bit(标记位)The CPU check bit before executed insructions. 模式由标记位指明。
OS events
interrupts are caused by external events Hard ware-generated Traps are caused by executing instructions Software-generated interrupts
System calls
when a user program needs to do something privileged,it calls a system call A system call is a special kind of trap Every ISA provides a system call instruction.
C2 OS Structures
user interfaces
system calls
操作系统的服务: program execution I/O Opertations file systems communciation resource allocation accounting (统计),protection and security what the compoments Various ways to structure OS MS-MOS
C3 Processes
how many process types:is an instance of a programming running on a computer
a system consists of a collection of processes: user process/OS process. active/passive dynamic/static,temporary/permanence. Draw diagram of process states: new->(admitted)ready->(scheduler dispatch)running->terminated (I/O or event completion)->waiting(I/O or event wait) what is pcb
Process control Block(PCB)
Identifier Process state CPU register What are the differences:process schedulers
What is context switch? When CPU switches to another process,the system save the state of the old process and load the saved state for the new process Context-switch time is overhead,while switching the system does not work. What are the ways of interprocess communication Shared memory Message system :Use message queues to enable process communication Blocking is considered synchronous(同步) Non -blocking is considered asyncronoys(异步)
C4 Threads
thread: a sequential executon stream within a process
benifits of the thread:
Pesonsiveness
Resource Sharing
Economy
Utilization of multi processor architecture:running in parrllels
lifecycle of a thread
Thread Types: User-level threads Kernel-supported threads
Many to one
one to one
Many to Many
What are the benefits of thread pool?
maintains multiple threads waiting for tasks to be allocated for concurrent execution
Servicing a request with an existing thread is faster than waiting to create a thread
Separating the task to be performed from the mechanics of creating the task allows us to use different strategies for running the task.