No one can do all things, learn to be good at use what others already did.

  • Most computers have two modes of operation: kernel mode and user mode. The OS is the most fundamental piece of software and runs in kermel mode(also called usperivosr mode). In this mode, OS has complete access to all the hardware and can execute any instruction th machine is capable of exectuing.
  • The rest of the software runs in user mode, in which only a subset of machine instructions are available. In particular, those instructions that affect control of machine or do I/O are forbidden to user-mode program.
  • The user interface program, shell or GUI(Launcher or home screen or destop), is the lowest level of user-mode program, and is used to allow uer to start other programs which make heavy use of the OS.
  • OS perform two basically unrelated functions:providing application programmer a clean abstract set of resources instead of the messy hardware ones and managing and managing these hardware resource.
  • Every hardware device has its controler chip, which has some command registers and data registers and status registers. What we shall do is to use machine instructions to operate these device registers with defined-well address(MMP) for reading and writing.
  • Abstraction is the key to managing complexity and one of the keys to understanding OS.
  • The job of the OS is to create/define good abstractions and then implement and manage the abstract objects thus created.
  • One of the major tasks of the OS is to hide the hardware and present programs with nice,clean, elegant, consistent, abstractions wo work with instead.
  • Top-down view, Bottom-Up view.
  • The CPU and memory are not the only resource that the OS must manage. I/O devices also interact heavily with the OS.
  • I/O devices generally consist of two parts: a controller and the device itself. The controller is a chip or a set of chips that physically controls the device.It accepts commands from the the OS, intialize the control regitser to set working way and read data from data register or write data to data registers.
  • The softeware that talks to a controller, giving it commands and accepting responses, is called a device driver.
  • Every device controller has a small number of registers that are used to communicate with it.
  • The collection of all the device registers forms the I/O port space, mapping to the specific memory via MMU
  • The device registers are mapped into the OS's address space, so they can be read and written like ordinary memory words, another way to interact with device registers is using special CPU instructions for I/O operation with defined port address.
  • OS normally use interrupt mechanism to interact with device driver via special interrupter controller connected to CPU.
  • The CPU talks to the PCI bridge chip over the local bus, and the PCI bridge chip talks to the memor over a dedicated memory bus.
  • Before plug and play, each I/O card had a fixed interrupt request level and fixed address for its I/O registers.
  • What plug and play does is have the system automatcially collect information about the I/O devices, centrally assign interrupt levels and I/O address, and then tell each card what its numbers are.
  • Window CE Driver Model:
    • Device Name: XXX_Init(), XXX_DeInit(), XXX_PowerDown(), XXX_PowerUp(),XXX_IOControl, XXX_Open(),XXX_Close(),XXX_Seek(),XXX_Read(), XXX_Write()
    • Use a class to define the detailed implementation
    • Create a class object (pointer) which is returned as Handle
    • Convert Handle into pointer to object, then call method of class
    • Create thread and event to handle interrupt, in thread there is a for(;;) loop with WaitForSingleObject() to wait for interrupt event, after done  call InterruptDone()
    • Register Interrupt handler which just signal a event.
    • Initialization method within class to access device's control registers, do some configuration, including interrupt handler
    • In thread, when interrupt event is coming, it will  read data from or write data into device's data registers.
    • Write Driver Information to registry and project.blb
  • Process And Thread
    • The most central concept in any OS is the process: an abstraction of a running program.
    • There are four principal events that cause processes to be created.
    • When an OS is booted, typically serveral processes are created.Some of these are foreground processes, interacting with users and perform work for them. Others are background processes with some specific function(such as Web Server).
    • The fork system call creats an exact clone of the calling process.After the fork, the two processes, the parent and child, have the same memory image, the same environment strings, and the same open files.
    • Some of the process run programs that carry out commands typed in by a user; other processes are part of the system and handle tasks such as carrying out requests for file services or managing the details of running a disk or a tape drive.
    • When a disk interrupt occurs, the system makes a decision to stop running the current process and run the disk process which was blocked waiting for that interrupt.
    • Instead of thinking about interrupts, we can think about user processes, disk processes, termianl processes, and so on, which block when they are waiting for something to happen.
    • Here the lowest level of the operating system is the scheduler, with a variety of processes on top of it.All the interrupt handling and details of actually starting and stopping processes are hidden away in what here called the scheduler, which is actually not much code.
    • The rest of the OS is nicely structured in process form.
    • To implement the process model, the OS maintains a table(an array of structures or a list of structures),called the process table, with one entry per process. Or it can be called process control block.
    • Process Table includes: process state, PC, SP, Memory allocation, the status of its open files, its accounting and scheduling information, and everything else about the process that must be saved when the process is switched from running to ready or blocked state so that it can ben restarted later as if it had never been stopped.
    • Associated with each I/O class is a location (typically at a fixed location near the bottom of memory) called the interrupt vector. It contains the address of the interrupt service procedure.
    • When interrupt come in, the interrupt service handler will run, and at the same time, before running the interrupt hardware will push current process's information into stack.
    • Skeleton designed when an interrupt occurs:
    1. Hardware stacks program counter(PC), etc;
    2. Hardware loads new program ounter(PC) from interrupt vector;
    3. Assembly language procedure saves registers;
    4. Assembly language procedure sets up new stack;
    5. C interrupt service runs(typically reads and buffers input);
    6. Scheduler decides which process is to run next;
    7. C procedure retursn to the assemly code;
    8. Assemly language procedure starts up new current process
    • ddd
    • dd

Modern Operating System的更多相关文章

  1. 《modern operating system》 chapter 5 Input and output 注意事项

    Input / Output It should also provide an interface between the devices and the rest of the system th ...

  2. 《modern operating system》 chapter 6 DEADLOCKS 笔记

    DEADLOCKS Both processes are blocked and will remain so forever. This situation is called a deadlock ...

  3. Portable Operating System Interface for uni-X

    https://kb.iu.edu/d/agjv Short for "Portable Operating System Interface for uni-X", POSIX ...

  4. General-Purpose Operating System Protection Profile

    1 Protection Profile Introduction   This document defines the security functionality expected to be ...

  5. book-rev8 Chapter 0 Operating system interfaces

    Chapter 0 第0章 Operating system interfaces 操作系统接口 The job of an operating system is to share a comput ...

  6. DBCC CHECKDB 遭遇Operating system error 112(failed to retrieve text for this error. Reason: 15105) encountered

    我们一个SQL Server服务器在执行YourSQLDBa的作业YourSQLDba_FullBackups_And_Maintenance时遇到了错误: Exec YourSQLDba.Maint ...

  7. The World's Only Advanced Operating System

    The World's Only Advanced Operating System

  8. Unable to open the physical file xxxx. Operating system error 2

    在新UAT服务器上,需要将tempdb放置在SSD(固态硬盘)上.由于SSD(固态硬盘)特性,所以tempdb的文件只能放置在D盘下面,而不能是D盘下的某一个目录下面. ALTER  DATABASE ...

  9. CREATE FILE encountered operating system error 5(Access is denied.)

    这篇博文主要演示"CREATE FILE encountered operating system error 5(Access is denied.)"错误如出现的原因(当然只是 ...

随机推荐

  1. Oracle数据库学习(四):学习中的遇到的问题

    一.xhost图形化界面安装问题 问题1:运行xhost +命令,出现命令没有找到错误 原因:Linux系统没有安装xhost图形化包. 解决办法:安装xhost图形化包,命令如下: yum what ...

  2. vue-cli3预设preset记录

    这两天公司搭建新项目的时候发现vue-cli3有一个神奇的的东西:preset(预设).preset其实是你在create新vue项目的时候,生成的插件配置项预设,也就是你在项目中需要用到的插件安装成 ...

  3. [Alpha]Scrum Meeting#8

    github 本次会议项目由PM召开,时间为4月10日晚上10点30分 时长15分钟 任务表格 人员 昨日工作 下一步工作 木鬼 撰写每日例会报告 撰写每日例会报告 SiMrua 优化模型速度(iss ...

  4. [ZJOI2019]语言[树链的并、线段树合并]

    题意 题目链接 分析 考虑枚举每个点的答案,最后除以 2 即可. 可以与 \(u\) 构成合法点对 的集合 为所有经过了 \(u\) 的链的并.因为这些链两两有交,根据结论 "树上两条相交的 ...

  5. 从源码层面解析SpringIOC容器

    Spring IOC容器继承关系图 MessageSource支持消息国际化.ResouceLoader资源加载.BeanFactory创建Bean.ApplicationEventPublisher ...

  6. Mac 10.12安装SecureCRT

    下载: (链接: https://pan.baidu.com/s/1eSNBoFC 密码: sztc) 安装参考: http://www.cnblogs.com/EasonJim/p/7568734. ...

  7. suse-Linux下安装Oracle11g服务器

    系统要求 Linux安装Oracle系统要求 系统要求 说明 内存 必须高于1G的物理内存 交换空间 一般为内存的2倍,例如:1G的内存可以设置swap 分区为3G大小 硬盘 5G以上 2.修改操作系 ...

  8. (转)OpenStack —— 原理架构介绍(一、二)

    原文:http://blog.51cto.com/wzlinux/1961337 http://blog.51cto.com/wzlinux/category18.html-------------O ...

  9. eclipse中怎样添加项目至SVN资源库

    转自:https://jingyan.baidu.com/article/642c9d341caac0644a46f73e.html 这是一个SVN最基本的一个使用方法,转一篇别人写的,方便日后查询. ...

  10. Elastic-Job源码分析之AbstractElasticJobExecutor分析

    还记得我们在JobScheduler中,在创建任务详情时,会调用一个建造器JobBuilder来创建一个Job,类型是LiteJob. LiteJob.java /** * Lite调度作业. * * ...