Showing posts with label operation system. Show all posts
Showing posts with label operation system. Show all posts

Thursday, 28 January 2016

OS notes

This semester will be end in the next week, there I clear up a lot of notes for Operating System.

History:

Why so differents?
-Because computing power is limited,more computing power,more complexity forces OS designers and vendors to simplify and reuse more components.




The possible hardware architectures: Asymmetric Multi-Processing and Symmetric Multi-Processing.An AMP system has multiple CPUs, each of which may be a different architecture (but can be the same. Like AMP, an SMP system has multiple CPUs, but in this case each has exactly the same architecture .
In AMP mode, each core has its own copy of a kernel, which could be different (heterogeneous operating systems) from, or identical (homogenous operating systems) to, the one the other core is executing.

In SMP mode, a single operating system (OS) runs on all processors, which access a single image of the OS in the memory. The OS is responsible for extracting parallelism in the application. It dynamically partitions tasks across the processors, manages the ordering of task completion, and controls the sharing of all resources between the cores.


Inside OS
1. Kernel: basic functionalities, syscalls
 2.Services: Accounts (login, nsswitch), Display Service
 3.Libraries: support functions, APIs (libc, libm, OpenGL)
 4.Applications: Web browser, Text Editor
 5.Support Applications: Terminal Emulator


Process

program: static object that contain code
processus: program in execution
context: address espace, registers, etc..


Communication between proccesses
Explicit communication
-automatic created by system
-uni or bidirectional link
-2 processes per link

Implicit communication
-link etablished with processes sharing the same port
-multipe processes per link
-uni or bidirectional link




Thread


a link note the difference between thread and process, in chinese:

http://blog.csdn.net/mxsgoden/article/details/8821936


Scheduling  



differents type of schedulers
-long term: which determines which programs are admitted to the system for execution and when, and which ones should be exited.(FCFS, Priority schemes)
-short term: which determines which of the ready processes can have CPU resources, and for how long.
-middle term: which determines when processes are to be suspended and resumed.(swapping)
-Cooperative:only block or terminated processes
-Preemptive:all type of events, needs for hardware support

When to schedule
-blocked processes
-terminate a process
-new process spawn
-blocked a process and becomes ready

Criteria
different criteria to consider when trying to select the "best" scheduling algorithm
○ CPU utilization
○ Throughput
○ Turnaround time
○ Waiting time
○ Response time


Differents scheduling algo
-FCFS:SCHED_FIFO, better for sharing time,
-Round Robin:
-Multiple priority queue
-Lottery scheduling:random ticket
-Completely Fair scheduling:
-Real Time scheduling

Memory Virtualization
In the cpu
-memory management unit
-page table/page directory: contains memory mappings
-page direction base pointer (PDBP): address to an address space
In the OS
-1 PDBP per task (isolated address space), 4096kb per page.




Thursday, 12 November 2015

深入计算机系统第一章(小笔记)

  计算机系统由硬件和软件组成,他们共同工作来运行应用程序。

文件:

比如一个hello.c的文件是由ASCII码组成的,是一个文本文件,但是在通过gcc hello -o hello.c编译以后,输出hello是二进制文件,由0和1组成。除了ASCII码构成的文件,其他都是二进制文件。
而hello.c的源程序实际上是由0和1组成的位(bit)序列,8个bits被组织称一组,成为字节(bytes),每个字节表示程序中某个文本字符,比如“#include”中的“#”在ascii码中就是35。

进程:

进程是操作系统对一个正在运行的程序的一种抽象。在一个系统上可以同时运行多个进程,而每个进程都好像在独占地使用硬件。如linux中,kernel会欺骗程序,所有的内存都是你的,并分配给它一小块内存,程序便高兴地占用了。
多个进程的运行是并发(concurrency)运行,意思就是一个同时具有多个活动系统,CPU同时处理多个进程,通过处理器在进程间不停地切换实现并发。操作系统实现这种交错执行的机制成为“上下文切换”。而通常说的“上下文”就是操作系统保持跟踪进程运行所需的所有状态信息。比如:PC和寄存器文件的当前值,主存内容。。。
另一个概念并行(Parallelism)也是计算机驱动进步的动力之一,指的是使用并发使一个系统运行更加快。

抽象:

抽象的使用是计算机科学组最为重要的概念之一。例如:为一组函数规定一个程序接口(API)就是一个很好的变成习惯。又例如在处理器里,指令集结构提供了对世纪处理器硬件的抽象,表现是机器代码程序表现得只执行了一条指令,然而底层的硬件比抽象描述的要复杂精细得多。
操作系统内核是应用程序和硬件之间的媒介。它提供三个基本的抽象:
-文件是对I/O设备的抽象
-虚拟存储器是对主存和磁盘的抽象
-进程是对处理器,I/O设备和主存的抽象
-网络提供了计算机系统之间的通讯手段,从特殊角度看,网络就是一种I/O设备。



MMU(memory management unit)