欢迎来到天天文库
浏览记录
ID:1705655
大小:118.00 KB
页数:27页
时间:2017-11-13
《the system-call interface》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、The‘system-call’interfaceWeseehowanapplicationprogramcaninvokeprivilegedkernelservicesRecallourpreviouslessonFirst,wepresenteda(simplified)diagramofthemajorcomponentsinamodernOSThen,wefocusedourattentionononeofthekernel’sinterfaces,namely,itsroleincontrollinghardware
2、devices(specificallytheIDEfixeddisk).Wesawtypicalcodeforperforminganactualdevice-command.Todaywelookatanotherkernelinterface.AModernOSDesignHardwareApplicationApplicationApplicationSharedRuntimeLibrariesuser-modesupervisor-modeSystemCallInterfaceDeviceDriverComponent
3、smemorymanagertaskmanagerfilemanagernetworkmanagerOSKernelOurdemo‘bypassed’theOSHardwareApplicationApplicationSharedRuntimeLibrariesuser-modesupervisor-modeSystemCallInterfaceDeviceDriverComponentsmemorymanagertaskmanagerfilemanagernetworkmanagerOSKernelApplication(i
4、dnumber)RequiredIOPL==3Roleof‘runtimelibraries’Tounderstandwhatroleisplayedbythekernel’sinterfacewith‘runtimelibraries,’let’sseehowwecouldgoaroundthem.Wecancreateademo-programthatdoesnotneedtousethestandardClibrary–itwillperformalltheirworkonitsown.Ifyoufireyourjanit
5、or,youwillveryquicklycometoappreciateallthathedidforyou!DemowillcallkerneldirectlyHardwareApplicationApplicationApplicationdemoSharedRuntimeLibrariesuser-modesupervisor-modeSystemCallInterfaceDeviceDriverComponentsmemorymanagertaskmanagerfilemanagernetworkmanagerOSKe
6、rnelAnormalCprogramexample#include//forwrite()#include//forexit()charmessage[]=“Hello!”;intmain(void){write(1,message,7);exit(0);}Standarddevice-filesWheneveranewprogramislaunched,theoperatingsystemwillautomatically‘open’threedevice-files,named‘
7、stdin’,‘stdout’,and‘stderr’,usingfile-drescriptors0,1,2.‘stdin’isthestandardinputdevice(keyboard)‘stdout’isthestandardoutputdevice(screen)‘stderr’isthestandarderrordevice(screen)StandardClibraryfunctionsThefunctions‘write()’and‘exit()’werenotactuallydefinedwithinourp
8、rogram-codeTheyareexamplesof‘external’functionsHeader-filesletthecompilerknowhowtogenerateassemblercodethatcallsthemTheiractualdefi
此文档下载收益归作者所有