1、1What is an operating system?DefinitionAn operating system is the“permanent”software that controls/abstracts hardwareUser applications can thus be simpler and device-independentphysical machine interfaceUser ApplicationsOperating SystemArchitecturevirtual machine interface2What is an operating syste
2、m?Definition(cont)Manages resources and processes to support different user applicationsProvides Applications Programming Interface(API)for user applicationsUser ApplicationOperating SystemArchitectureUser Application3Modern operating systemsx86 platform Linux WindowsMac platform Mac OSSun Solaris&U
3、nix(Sun workstations)IBM AIX(mainframes)Embedded systems(special-purpose OS)Palm,PocketPC,etc Xbox,etc4Linus Torvalds1991,Finland,Linux Project1992,Linux Kernel 0.02 Bash v1.08 GCC v1.401997,Moves to Transmeta1998,Linux Kernel v2.22001,Linux Kernel v2.4Pronunciation:“Linn-ucks”5Windows 2000&XP1989:1
4、0 developers left DEC VMS team and joined Microsoft Windows NT 1.01996:Windows NT 4.01999:Windows 20002001:Windows XP2002:Microsoft.Net Server6Linux vs.Windows NTLinux is kernel only,free and open sourceWindows is full-loaded OS and pricyLinux requires minimum HW,Windows notWeb server(Win2K+SWC)beat
5、s(Linux+TUX)File server&printer server Windows supports a wider range of HW Linux has more stable drivers7Operating System Interfacesdocin/sundae_meng8Software&hardware layerUser ProgramExecutable BinaryCompilerLinkerSystem libraryArchitectureusercompilerOS interfaceOSHardwaredevice driversOperating
6、 Systemkerneluser mode9Device DriverDevice driver的唯一目的就是要將所有的硬體隱藏.他應該是整套軟體中唯一能和硬體溝通的窗口.他能直接讀取或寫入特定裝置控制及狀態暫存器,如果裝置發生中斷,那ISR也要整合到裝置驅動程式.10System service call(monitor)C Programs:main()/call printf,provided/by the C library,to/print on the screenprintf(“Hello World!”);Borland C library:Borland C library
7、:Int Int printf()printf()/call SysOutputString,/call SysOutputString,/provided by NT/provided by NT/system library,to/system library,to/print on the screen/print on the screenSysOutputString();SysOutputString();NT library:NT library:Void Void SysOutputStringSysOutputString()()/call NtOutputString,th
8、at in turn will call/call NtOutputString,that in turn will call/video card driver to output strings to/video card driver to output strings to/the screen/the screenNtOutputString();NtOutputString();11System service call(disk)C Programs:main()/call CreateFile/by the C library,to/create a file on diskC
9、reateFile(“a.txt”)Borland C library:Borland C library:Int CreateFile()/call NtCreateFile,/provided by NT to/create a fileNtCreateFile();NT library:NT library:Void NtCreateFile()/call NtInternalCreateFile,that in turn will /call the file system driver and the disk /driver to create a file on a disk N
10、tInternalCreateFile();12System service calls(network)C Programs:main()so=createsocket();send(so,“text”);close(so);Borland C library:Borland C library:int createsocket()NtCreateSocket();int send()NtSocketSend();NT library:NT library:Void NtCreateSocket()NtAfdCreateSocket();1314Virtual computer concep
11、tC+compilerFORTRAN compilerC compilerJava compilerAssemblerOperatingSystemCommandinterpreterLISP interpreterOperating systemMacroinstruction interpreterBare machineVirtual CComputerVirtual C+Computer15Importance of operating systemSystem API are the only interface between user applications and hardw
12、are API are designed for general-purpose,not performance driven(work applications)OS code cannot allow any bug Any break(e.g.invalid access)causes rebootThe owner of OS technology controls the software industry16What is Embedded System?是電腦軟體與硬體的綜合體,亦可涵蓋機械或其他附屬裝置;整個綜合體設計的目的,在於滿足某種特殊功能.例如:PDA,遊樂器,衛星導航
13、系統,流程管理器 等.docin/sundae_meng17Embedded system architecture3-layered device Palm,PocketPCUser ApplicationsEmbedded OSHardware2-layered device XBoxHardwareApplication18General-purpose&embedded OSGeneral-purpose Embedded OSExamplesLinux,WindowsWinCE,Palm OSHardwareGeneral-purpose Special deviceOS code
14、sizeLargeSmallStability req.StrongWeakDevelop.costHugeMedium19Operating system conceptsdocin/sundae_meng20Process&ThreadHow do different applications run on the same machine at the same time without interfering each other?Protection between processes Protection between a process and the OSProcess:an
15、 execution of a program,consisting of a virtual address space,one or more threads,and some OS states.21Virtual memory(address space)0232-1virtual address space(4GB)page 0page 1page 2page 220vap0vap1xpage tablephysical memory(16MB)pp 0pp 1pp 2pp Npaging filepp 212x22Virtual memory(address space)0232-
16、1virtual address space(4GB)page 0page 1page 2page 220vap0vap1xpage tablephysical memory(16MB)pp 0pp 1pp 2pp Npaging filepp 21223Memory managerphysical memorypp 0pp 1pp 2pp Npaging filepp 212process VAprocess VAPTPT24Memory manager physical memorypp 0pp 1pp 2pp Npaging filepp 212process VAprocess VAP
17、TPT25Memory manager(w/constraint)physical memorypp 0pp 1pp 2pp Npaging filepp 212process VAprocess VAPTPTxmemory manager26Protectiondual mode operationCan application modify its own page table?If it could,could get access to all physical memory.Dual Mode Kernel/protected model:no restriction,can tou
18、ch any physical memory page User mode:where you program runs,can only touch part of the virtual address spaceApplications can enter the kernel mode through systems calls(traps)27Mode change:system call trap1.System call traps to the kernel(kernel mode)2.Kernel determines service routine required3.Ke
19、rnel services the call.4.Control is returned to user program(user mode)28ThreadA process starts with one thread(main thread),and can initialize more threads by CreateThread()callsA thread represents an execution stream of instructions and its CPU register contextA thread is the unit used in the sche
20、dulerKill a process kill its all threads29SchedulerA component in OS that decides which thread in the thread pool gets the CPUPriority-based schedulerContext switchnew threadschedulerreadyrunningwaitingterminatingthreadssignalevents30SynchronizationAll threads in the same process share all global da
21、taSynchronization among these threads is necessary to maintain data integrityResource lock is commonly used to guarantee thread mutual exclusive abuse of such locks decreases scalability ignorance of such locks decreases stabilityDeadlock issues31File SystemsA hard disk is just a raw media storageA
22、hard disk device driver allows OS to communicate with the hardwareBut,it is the responsibility of the OS to organize disk sectors/tracks for storing files such component is called the file systemE.g.A hard disk that stores NTFS information cannot be read with the FAT32 driver example:paper with Mose
23、s code32Operating Systems and System SoftwareExample:web server softwaredocin/sundae_meng33User-mode web server architectureWeb ServerCMweb cachenetwork cardTCPIPUser ModeKernel ModeI/O moduleSocketSystem CacheFileSys34User-mode web server commonsUser-mode application architecture e.g.Microsoft Inte
24、rnet Information Server(IIS),Netscape Enterprise Server,Apache HTTP Server,etc.Dependent on generally system APIStand-alone web content cache limited by virtual address spaceTime-to-live cache replacement algorithmMemory-less dynamic code execution35SWC web server architectureUser ModeKernel ModeTCP
25、IP-NTFSCMweb cachenetwork card+System CacheSWCmissI/O ModuleTWC.LIBUser CodeVAPAhit36SPECWEB99 Performance*estimated scaling data37Kernel vs.user-based web serverIncrease peak capacity by five timesWeb cache size be limited by physical memory sizeWeb cache be shared by both static&dynamic web requestsRemove I/O overhead and Socket creationFast TCPIP data transmission38Summary#personsmanyfew skillseasydifficultcontrolsmalllargerewardlowhighAppsEOSA.D.1492 Columbus discovers America-The new and free land is on your grip!
侵权处理QQ:3464097650--上传资料QQ:3464097650
【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。