ostep02--The Abstraction:The Process
来源:互联网 发布:淘宝网在哪里买基金 编辑:程序博客网 时间:2024/06/05 18:36
ostep02–The Abstraction:The Process
process
The definition of a process,informally,is quite simple:it is a running program
The program itself is a lifeless thing:it just sits there on the disk,a bunch of instructions,waiting to spring into action.
It is the OS that take these bytes and gets them running,transfroming the program into something useful
many programs running at the same time?
OS create this illustration by virtualizing the CPU
The basic technique is time sharing of CPU
how to implement above target?
low-level machinery
mechanism
context-switch
time-sharing
high-level intelligence
policy
scheduling algorithm
machine stat
address space:the memory that the process can addressregisters: program counter(PC):which instruction of the program is currently being executed stack pointer: frame pointer: manage the stack for function parameters、local variables and return addresspersistent information:a list of files...
process API
Create:create new processesDestroy:destroy processes forcefullyWait:wait for a process to stop runningMiscellaneous Control:suspendStatus:get process status information
how programs are transformed into processes
load its code and any static data (e.g., initialized variables) into memory, into the address space of the process. Programs initially reside on disk in some kind of executable format. eagerly lazily paging swapping
-
allocate memory for program's <font color=099ff size=5 face="΢ÈíÑźÚ">run-time stack</font>.(C programs use the stack for local variables,function parameters,and return addresses).also likely initialize the stack with arguments such as argc、argv
-
create some inital memory for the program's <font color=099ff size=5 face="΢ÈíÑźÚ">heap</font> .In C programs, <font color=099ff size=5 face="΢ÈíÑźÚ">the heap is used for explicitly requested dynamically-allocated data</font> ; programs request such space by calling <font color=099ff size=5 face="΢ÈíÑźÚ">malloc()</font> and free it explicitly by calling <font color=099ff size=5 face="΢ÈíÑźÚ">free()</font> . The heap is needed for data structures such as linked lists, hash tables, trees, and other interesting data structures. The heap will be small at first; as the program runs, and requests more memory via the malloc() library API, the OS may get involved and allocate more memory to the process to help satisfy such calls.
-
initialization tasks:in UNIX systems,each process by default has three open <font color=099ff size=5 face="΢ÈíÑźÚ">file descriptors</font> ,for standard input,output and error
-
to start the program running at the entry ,namely <font color=099ff size=5 face="΢ÈíÑźÚ">main()</font>
process state
Running
In the running state,a process is running on a processor.This means it is executing instructions
Ready
In the ready state,a process is ready to run but for some reason the OS has chosen not to run it at this given time
Blocked
In the blocked state,a process has performed some kind of operation that makes it not ready to run until some other event takes place.e.g.:Initiate an I/O request to a disk.
process data structures
process list
keep track of all process that are ready
with additional information to track running processes
and some blocked processes
information to track
register context
process state
sleeping\running\runnable\zombie…
initial state:process being created
final state:process being exited but not cleaned up
the parent process can use final state to examine whether the child executed successfully
PCB
Process Control Block
individual structure that stores above information
- ostep02--The Abstraction:The Process
- The OMNI Thread Abstraction
- The progress of abstraction (抽象过程)
- The Abstraction: Address Spaces(地址空间)
- Optimizing the “One Big Switch” Abstraction笔记
- The C# Design Process
- The Linux Process Manager
- The Inspection Process
- The process of testing
- The C# Design Process
- The Linux Process Manager
- The Kernel Boot Process
- The Linux Boot Process
- The Android boot process
- The ClientLogin authorization process
- The Kernel Boot Process
- The birth-death process
- The Kernel Boot Process
- UITextField修改placeHolder颜色
- Android - 资源的定义和引用
- 【杭电oj】1090 - A+B for Input-Output Practice (II)
- 面试题52:不能被继承的类
- 如何选择 compileSdkVersion, minSdkVersion 和 targetSdkVersion
- ostep02--The Abstraction:The Process
- c++ 对象的复制与赋值
- android 点击Edittext时hint值不自动隐藏问题
- Android退出所有Activity最优雅的方式
- GIT - 日常操作(1)
- 树莓派配置交叉编译环境
- android头像设置:从本地照片库或拍照获取并剪裁
- CodeForces 609B The Best Gift
- 浅谈ClickableSpan , 实现TextView文本某一部分文字的点击响应