: Introduction To OS)
笔者这学期在澳科大当交流生故这学期开始在这里分享澳科大这边课程的笔记先从《操作系统》课程开始吧。What is an Operating System?Most computers have two modes of operation:kernel modeanduser mode.OS runs inkernel mode(also called supervisor mode), which hascomplete access to all hardware and can execute any instruction.Rest of software runs inuser mode, which haslimited capability.Shell or GUI is the lowest level of user mode software.The user does not have to program the hardware directly, because OS hides all the troublesome operations of the hardware.Process is a running image of a program.Users are not working with the OS directly. Whatever programs you run, it behaves as processes.How to interact with the OS?For an ordinary users:OS is a “thing” that is able for them to store programs and run programs.For programmers:OS is a piece of software that allows them to:to interact with the user, by the OS for the I/O interface.to interact with the OS itself, by the OS for the system calls.For hardware driver programmers:OS is a piece of software that allows them to host the driver programs.System CallsKernel is the core of a computer’s OS, with complete control over everything in the system.System callsare the programming interface between processes and the OS kernel. The system calls are usuallyprimitive, important, fundamental.SummaryIn summary, an OS isa piece of software;a resource manager, which manages all the physical devices,a service provider, which provides a set of programming interfaces for processes to access to the resources.ProcessProgram ≠ ProcessA process is anexecution instanceof a program.More than one process can execute the same program code.A process is notbounded to execute just one program!A process is an active entity.A process has itslocal statesconcerning the execution. E.g., which line of codes it is running, and which CPU core (if there are many) it is running on.The local states change while running.Process Relationship (Tree Hierarchy)Process StateRunning (using CPU)Ready (runnable, but temporarily stopped to let another process run)Blocked (cannot run until some external event happens)MemoryMemory HierarchyA program is fetchedfrom hard disk to main memoryby OS.When executed, instructions in the program are fetchedfrom the main memory to CPU.The hierarchy does not just fit the program execution flow, but also forstoring processes, including the states of the processes.Process are stored at different devices controlled by the OS before they get a chance to runbecause there is only a finite number of CPUs (1-2) and only a finite number of processes can be executed“really at the same time”.Global variables, local Variables, dynamically allocated memory, and program code and constantsare the things a process has to stored in memory.File SystemA file system (FS) means the way that a storage device is used.A file systemmustcontain the following components:directories;files;allocated space;free space.Thestable sideof the file system: a file system is abouthow files are stored; apart from files, many other things are stored in the disk.Thedynamic sideof the file system: a file system is also aboutthe operations which update the content of the file system.A FS is independent of an OS:If an OS supports a FS, then the OS can do whatever operations over that storage device.Else, the OS doesn’t know how to read or update the device’s content.