{"id":716,"date":"2014-01-11T15:41:00","date_gmt":"2014-01-11T07:41:00","guid":{"rendered":"http:\/\/note.systw.net\/note\/?p=716"},"modified":"2023-11-04T15:44:30","modified_gmt":"2023-11-04T07:44:30","slug":"system-structure","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/716","title":{"rendered":"System Structure"},"content":{"rendered":"\n<p><strong>A view of system structures<\/strong><br>user and programs<br><strong>[user interfaces]<\/strong><br>[system calls]<br><strong>[operating system services]<\/strong><br>hardware<\/p>\n\n\n\n<p><strong>user interfaces<\/strong><br>\u5e38\u898b\u7684\u6709\u4ee5\u4e0b<br>CLI(command line interface)<br>GUI(graphic user interface)<br>Touchscreen interfaces<\/p>\n\n\n\n<p><strong>operating system services<\/strong><br>\u5e38\u898b\u7684service\u6709\u4ee5\u4e0b<br><strong>program execution<\/strong>:\u8f09\u5165\u7a0b\u5f0f\u9032\u5165memory\u4e26\u57f7\u884c<br><strong>I\/O operations<\/strong>:<br><strong>file-system manipulation<\/strong><br><strong>communications<\/strong>:processes may exchange information<br><strong>error detection&nbsp;<\/strong>ex:error\u5305\u62eccpu\u904e\u71b1\u7576\u6a5f,memory\u640d\u58de,&#8230;\u7b49<br><strong>resource allocation<\/strong>:\u5354\u8abf\u8cc7\u6e90\u5206\u914d<br><strong>accounting<\/strong>: \u8ffd\u8e64process\u7684\u72c0\u6cc1<br><strong>protection and security<\/strong><\/p>\n\n\n\n<p><br>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..<\/p>\n\n\n\n<p><strong>system calls<\/strong><br>programming interface to the services provided by the OS<br>ps:<br>\u5927\u90e8\u4efd\u900f\u904eAPI\u4f86\u5b58\u53d6OS services\uff0c\u5f88\u5c11\u76f4\u63a5\u4f7f\u7528system calls<\/p>\n\n\n\n<p><strong>system call API<\/strong><br>\u5e38\u898b\u7684\u6709\u4ee5\u4e0b<br>win32 API, for ms windows<br>POSIX API, for unix,linux,mac os x<br>java API, for java virtual machine<br>ps:<br>API\u5b58\u53d6\u5931\u6557\u6642\u901a\u5e38\u6703\u56de\u50b3 -1<\/p>\n\n\n\n<p><strong>system call interface<\/strong><br>\u4e3b\u8981\u5206\u4ee5\u4e0b\u5169\u7a2e<br><strong>user mode<\/strong>:system call interface\u8207user application\u6e9d\u901a<br><strong>kernel mode<\/strong>:system call interface\u8207kernel\u6e9d\u901a<\/p>\n\n\n\n<p><strong>system call parameter passing<\/strong><br>\u5e38\u898b\u65b9\u6cd5\u6709\u4e09\u7a2e<br><strong>registers<\/strong>:\u6700\u7c21\u55ae\u7684\u65b9\u6cd5,parameter\u653e\u5728registers<br><strong>block<\/strong>:parameter\u5b58\u5728block or table, memory,&#8230;\u7b49, linux,solaris\u4f7f\u7528\u8a72\u65b9\u6cd5<br><strong>stack<\/strong>:parameter\u900f\u904eprogram\u653e\u5728\u6216pushed\u5230stack<\/p>\n\n\n\n<p>&#8230;<\/p>\n\n\n\n<p><strong>class of system calls\u3000<\/strong><br>\u4e3b\u8981\u4f9d\u529f\u80fd\u5206\u70ba\u4ee5\u4e0b\u5e7e\u7a2e<\/p>\n\n\n\n<p><strong>process control<\/strong><br>\u5e38\u898b\u5de5\u4f5c\u5982\u4e0b<br>create\/terminate process<br>get\/set process attributes<br>wait for time,event,singal event<br>ex:<br>win: CreateProcess(),ExitProcess(),WaitForSingleObject()<br>unix: fork(),exit(),wait()<\/p>\n\n\n\n<p><strong>information maintenance<\/strong><br>\u5e38\u898b\u5de5\u4f5c\u5982\u4e0b<br>get\/set time or date<br>get\/set system data<br>get\/set process,file,device attributes<br>ex:<br>win: GetCurrentProcessID(),SetTimer(),Sleep()<br>unix: getpid(),alarm(),sleep()<\/p>\n\n\n\n<p><strong>file management<\/strong><br>\u5e38\u898b\u5de5\u4f5c\u5982\u4e0b<br>craete\/delete\/open\/close file<br>read\/write\/reposition device management<br>ex:<br>win: CreateFile(),ReadFile(),WriteFile(),CloseHandle()<br>unix: open(),read(),write(),close()<\/p>\n\n\n\n<p><strong>communications<\/strong><br>\u5e38\u898b\u5de5\u4f5c\u5982\u4e0b<br>create\/delete communication connection<br>message passing\/shared-memory model<br>ex:<br>win: CreatePipe(),CreateFileMapping(),MapViewOfFile()<br>unix: pipe(),shmget(),mmap()<\/p>\n\n\n\n<p><strong>device management<\/strong><br>\u5e38\u898b\u5de5\u4f5c\u5982\u4e0b<br>request\/release\/read\/write device<br>get\/set device attributes<br>ex:<br>win:SetConsoleMode(), ReadConsole(),WriteConsole()<br>unix:ioctl(),read(),write()<\/p>\n\n\n\n<p><strong>protections<\/strong><br>\u5e38\u898b\u5de5\u4f5c\u5982\u4e0b<br>control access to resources<br>get\/set permissions<br>allow\/deny user access<br>ex:<br>win:SetFileSecurity(), InitlializeSecurityDescriptor(), SetSecurityDescriptorGroup()<br>unix:chmod(),umask(),chown()<\/p>\n\n\n\n<p><br>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<\/p>\n\n\n\n<p><br><strong>system kernel<\/strong><br>\u4f5c\u696d\u7cfb\u7d71\u6700\u57fa\u672c\u7684\u90e8\u5206<br>\u56e0\u4f7f\u7528\u983b\u7387\u9ad8,\u6240\u4ee5\u5e38\u99d0\u65bc\u8a18\u61b6\u9ad4\u4e2d<br>\u57fa\u672c\u529f\u80fd\u5305\u542b<br>\u3000interrupt handling(\u8655\u7406\u4e2d\u65b7)<br>\u3000process creation and destruction(\u8655\u7406\u55ae\u5143\u7684\u5efa\u7acb\u8207\u4e2d\u6b62)<br>\u3000process state switching(\u8655\u7406\u55ae\u5143\u7684\u72c0\u614b\u8f49\u63db)<br>\u3000dispatch(\u5206\u914dCPU \u7684\u4f7f\u7528\u6b0a)<br>\u3000process synchronization(\u8655\u7406\u55ae\u5143\u4e4b\u9593\u7684\u540c\u6b65)<br>\u3000I\/O operation(\u8655\u7406\u8f2a\u51fa\/\u8f38\u5165)<br>ps:<br>kernel \u4e5f\u7a31\u70banucleus<\/p>\n\n\n\n<p><br><strong>System Structure<\/strong><br>\u5e38\u898b\u7684\u6709\u4ee5\u4e0b<br><strong>Simple Structure(\u7c21\u6613\u67b6\u69cb)<\/strong><br>\u3000\u4f9d\u7576\u6642\u7684\u9700\u6c42\u8207\u74b0\u5883\u76f4\u63a5\u8a2d\u8a08<br>\u3000\u512a\u9ede:\u4e0d\u9700\u8003\u91cf\u672a\u77e5\u7684\u96e3\u984c,\u8f03\u5bb9\u6613\u8a2d\u8a08<br>\u3000\u7f3a\u9ede:\u7121\u6574\u9ad4\u898f\u5283,\u7cfb\u7d71\u5bb9\u6613\u96dc\u4e82\u800c\u4e92\u76f8\u5e72\u64fe<br>\u3000ex:MS-DOS<br><strong>Layered Approach(\u968e\u5c64\u67b6\u69cb)<\/strong><br>\u3000\u7b2c N \u5c64\u7684\u57f7\u884c\u80fd\u529b\u4f86\u81ea\u7b2c N-1 \u5c64\u63d0\u4f9b\u7684\u670d\u52d9<br>\u3000\u512a\u9ede:\u6574\u9ad4\u7cfb\u7d71\u6c92\u6709\u8907\u96dc\u727d\u626f\u7684\u5e72\u64fe<br>\u3000ex:os\/2<br><strong>Microkernel(\u5fae\u6838\u5fc3)\/Mach<\/strong><br>\u3000\u5c07\u6240\u6709\u5728kernel\u4e2d\u975e\u5fc5\u8981\u7684\u529f\u80fd,\u4ee5modules\u7684\u65b9\u5f0f\u5448\u73fe<br>\u3000module\u4e5f\u7a31\u70baLoadable Kernels(\u53ef\u8f09\u5165\u6838\u5fc3)<br>\u3000kernel\u4e5f\u7a31\u70bacore kernel<br>\u3000\u512a\u9ede:<br>\u3000\u3000\u8b93kernel\u8b8a\u5c0f\u4e5f\u4e0d\u6703\u5931\u53bb\u539f\u6709\u7684\u529f\u80fd<br>\u3000\u3000\u53ef\u89e3\u6c7a\u4f5c\u696d\u7cfb\u7d71kernel\u592a\u5927\u6642\u8f03\u96e3\u7ba1\u7406\u7684\u554f\u984c<br>\u3000ex:linux<br>ps:<br>hybrid \u7d50\u69cb:\u8868\u793a\u5169\u500b\u4e0d\u540c\u4f86\u6e90\u7684OS\u4f5c\u7d50\u5408&nbsp;<br>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.<\/p>\n\n\n\n<p><strong>\u5e38\u898b\u7684OS\u7cfb\u7d71\u7d50\u69cb<\/strong><\/p>\n\n\n\n<p><strong>OS\/2<\/strong><br><strong>architecture<\/strong><br>layer4:application<br>layer3:application programming interface<br>layer2:subsystems<br>layer1:system kernel<br>layer0:device driver<\/p>\n\n\n\n<p><br><strong>Mac OS X<br>architecture<\/strong><br>layer3: GUI<br>\u3000 Aqua<br>layer2: application enviroments and services<br>\u3000 Jaca,Cocoa,Quicktime,BSD<br>layer1: kernel enviroment<br>\u3000Mach,BSD<br>\u3000I\/O kit,kernel extenions<\/p>\n\n\n\n<p><strong>iOS<\/strong><br>\u4fee\u6539\u5f8c\u7684Mac OS X<br><strong>architecture<\/strong><br>layer4: Cocoa Touch<br>layer3: Media Services<br>layer2: Core Services<br>layer1: Core OS<\/p>\n\n\n\n<p><strong>android<\/strong><br>\u985e\u4f3cIOS,\u4fee\u6539\u7248\u7684linux<br><strong>architecture<\/strong><br>layer2:application framework<br>layer1:<br>\u3000 libraries[SQLite,openGL,surface manager,media framework,webkit,libc]<br>\u3000 android runtime[Core Libraries,Dalvik virtual machine]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A view of system structuresuse &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[22],"tags":[],"class_list":["post-716","post","type-post","status-publish","format-standard","hentry","category-operationsystem"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/comments?post=716"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/716\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}