{"format":"brushup-mindmap-v1","id":"os-00-sheet0","title":"总画布","structure":"mindmap","theme":"auto","root":{"id":"b9aa22deba98b3b20c7ac8aca2","topic":"🖥操作系统","expanded":true,"children":[{"id":"a2284019-c97d-4a14-af44-7ba0ca7eab40","topic":"基本概念","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/operating-systems/os-00-sheet1","expanded":false,"maxHeight":260,"doc":{"format":"brushup-mindmap-v1","id":"os-00-sheet1","title":"基本概念","structure":"timeline-h","theme":"auto","root":{"id":"07bba7a6bbbb12bd5eecf9c3fd","topic":"基本概念","expanded":true,"children":[{"id":"3fd807a1163af0db631eca7253","topic":"操作系统基本概念","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-44b04ee4db8d01.svg"},"children":[{"id":"344a0ef55e0b72e597c8eaa98c","topic":"操作系统概念","expanded":true,"children":[{"id":"f61ba9c2bb0a1f92f7fb2af74e","topic":"操作系统（operating system，简称OS）是管理【计算机硬件】与【软件资源】的【计算机程序】。操作系统需要处理如管理与配置内存、决定系统资源供需的优先次序、控制输入设备与输出设备、操作网络与管理文件系统等基本事务。操作系统也提供一个让用户与系统交互的操作界面。","expanded":true}]},{"id":"4c3be52ff568ef977cbb8b710f","topic":"四大特征","expanded":true,"children":[{"id":"7df861f92789c992d40a5be279","topic":"并发","expanded":true,"children":[{"id":"13a8222d646bec1abb134a0dbe","topic":"两个或多个事件在同一时间间隔发生","expanded":true,"style":{"background":"#FF9595"}},{"id":"e8282e433279fe30cd90290694","topic":"并行","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e2680c922f993fc36f5f88d4aa","topic":"多流水线或者多CPU可以实现并行","expanded":true},{"id":"b80935c66299bd81200e582422","topic":"在同一时间同一时刻","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"a28859c7157a3bfe1ffff95770","topic":"引入进程目的就是让程序可以并发","expanded":true},{"id":"56181036599abb480c41a85748","topic":"【宏观并行，微观并发】","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"73ff7d13-05c5-478c-aecc-8b07edb63249","topic":"并发：两个程序一个CPU，依次轮询使用1ms，宏观上看是同时处理了两个程序","expanded":true}]},{"id":"97293c4ff87b003b84df098aba","topic":"并发是资源共享的基础，若OS不支持并发，则不存在共享","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"4b0db139-601b-4896-9451-e075d304617b","topic":"A在使用资源，此时A还没有结束进程，B就想来使用，A让给了B：【能并发、有共享】","expanded":true}]}]},{"id":"10eaab2d04693eb909bf59f42c","topic":"共享","expanded":true,"children":[{"id":"03e9d6310bdb1e5a5bfca916f7","topic":"指资源共享","expanded":true,"style":{"background":"#FF9595"}},{"id":"6a897a929e08ec49d5703b19eb","topic":"互斥资源共享","expanded":true,"children":[{"id":"d2ba2a6e4aeae6d60c78b98fc8","topic":"在一段时间内，无论宏观微观都不可以同时访问","expanded":true,"style":{"background":"#FF9595"}},{"id":"8e1a4878b678a8ac63e47ab8bd","topic":"如打印机、磁带机","expanded":true},{"id":"aa68f45c095a344bd78259b6ae","topic":"互斥式共享","expanded":true,"children":[{"id":"0b1b61018f4be91aa9079a2054","topic":"进程A访问完才可以释放，才允许另一进程访问","expanded":true}]},{"id":"72b91027669a9421cf4b6aecef","topic":"独占资源/临界资源","expanded":true,"children":[{"id":"304839fde369b69dae0ca94d8c","topic":"一段时间内只允许一个进程访问的","expanded":true}]}]},{"id":"7479fbe26a6a4b497c526beac4","topic":"同时访问方式","expanded":true,"children":[{"id":"48cb934e9219009caf3cda50ef","topic":"在一段时间内，宏观上同时访问微观上分时访问","expanded":true}]},{"id":"f87b1d44505957a2915ffa4927","topic":"OS对共享资源的管理会影响到并发执行的情况","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"43e8674db448d4c5523e4bf7da","topic":"虚拟","expanded":true,"children":[{"id":"511bcdc7c848c2ed7c72784d10","topic":"把一个物理实体变为若干逻辑上的对应物","expanded":true,"style":{"background":"#FF9595"}},{"id":"cc5b4c92f76ab2dbe1eefa2de1","topic":"虚拟处理器","expanded":true,"children":[{"id":"9ecadedf3cd95d10740c19091f","topic":"利用多道程序设计技术把一个物理上的CPU虚拟为多个逻辑上的CPU","expanded":true,"children":[{"id":"fb7b72aeb89a2f325faae97c6f","topic":"通过并发","expanded":true}]}]},{"id":"471b0776edfa00255cd22a6b53","topic":"虚拟内存","expanded":true,"children":[{"id":"92b8c9c4d2ea9c87965f48fa55","topic":"虚拟存储器","expanded":true},{"id":"96386650509ad4e39d8d1b200a","topic":"把物理存储器转变为虚拟存储器，以从逻辑上扩充存储器容量","expanded":true}]},{"id":"087b6afd648b0bc5a49c8b1601","topic":"虚拟外部设备","expanded":true,"children":[{"id":"f4085c0e87a91d1de20fd8a054","topic":"将一台物理IO设备虚拟为多台逻辑IO设备","expanded":true,"children":[{"id":"bb079499-da3c-4f80-85ee-b0ce3b1694d0","topic":"Spooling技术","expanded":true}]}]}]},{"id":"7e7bfc5e64ca9afaebf8492943","topic":"异步","expanded":true,"children":[{"id":"84cab7775459fb396ede6a954d","topic":"进程是以不可预知的速度向前推进的，这就是进程的异步性","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"5ae9fb919139b02200840a6501","topic":"目标和功能","expanded":true,"children":[{"id":"829822f284b8192797222aafa2","topic":"系统资源的管理者","expanded":true,"children":[{"id":"1cfa27b8097a6047a4dd29a3c1","topic":"处理机管理","expanded":true,"children":[{"id":"579b554d562ae7305d1ccbdba2","topic":"进程","expanded":true}]},{"id":"0b6b71d8cc1ae009c528a9d91d","topic":"存储器管理","expanded":true,"children":[{"id":"be68b24ea0a96ab0babaeb8c87","topic":"内存","expanded":true}]},{"id":"1ce83e9e704bff9fd1fc6837c5","topic":"文件管理","expanded":true,"children":[{"id":"e8ba06a3ee0b7ab933a39afade","topic":"文件","expanded":true}]},{"id":"2b88a23ab86a36c1faef69f867","topic":"设备管理","expanded":true,"children":[{"id":"7858a839dbd9dfe6e060d9072e","topic":"IO","expanded":true}]}]},{"id":"059b6c783ccad6b156c73a55c9","topic":"用户和硬件的接口","expanded":true,"children":[{"id":"e21987983c290b306fff784618","topic":"命令接口","expanded":true,"children":[{"id":"0ecb7e938b1a1d3a818abaa1ea","topic":"联机","expanded":true},{"id":"b8eabc09ab88ce16493f387338","topic":"脱机","expanded":true}]},{"id":"13e993ef0058487eacd2796a62","topic":"程序接口","expanded":true,"children":[{"id":"708afe9333198cc9305fbadeb1","topic":"使用GUI","expanded":true}]}]},{"id":"bca8fd3eb0e9c2c91f08cb4077","topic":"用作扩充机器","expanded":true,"children":[{"id":"15e95706b978cfaf73ae9b8d72","topic":"没有任何软件支持的计算机称为裸机","expanded":true},{"id":"e8ebe166ef1a04a379181b087b","topic":"覆盖了软件的机器为扩充机器、虚拟机","expanded":true}]}]},{"id":"751fc4c9-c59c-4649-80a7-49c3e41941a4","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"dddfbb1b-aea1-49fa-ae48-2db6f8163eea","topic":"09、10、13、22","expanded":true}]}]},{"id":"bf89ec3435481989f6a278bd3c","topic":"操作系统的发展和分类","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-585f1b7054eb27.svg"},"children":[{"id":"9f5b1fa5-8a43-45ab-b8d8-fd52b586920b","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"69fb638e-637d-4094-b6ae-d5f8c2559a48","topic":"16、17、18","expanded":true}]},{"id":"d5e8ef5464ca777d6238e90901","topic":"手工操作","expanded":true,"children":[{"id":"a76beb3f7fca545a8050fbb7e1","topic":"需要大量的时间进行人工处理，输入输出以及计算机计算的时候微乎其微","expanded":true},{"id":"66ab88f473ba64f4e4acdb83fa","topic":"缺点：","expanded":true,"children":[{"id":"e4ea51e4c34974d3d294393884","topic":"用户独占全部、资源利用率低、CPU等待手工操作、CPU利用不充分","expanded":true}]}]},{"id":"d30b0dbe322aa4f9a961e9cbcf","topic":"批处理阶段","expanded":true,"children":[{"id":"28494a7bf63a830966bea91cef","topic":"单道批","expanded":true,"children":[{"id":"638b72f3456805899832facfb9","topic":"自动性、顺序性、单道性","expanded":true,"children":[{"id":"2c9a7c34ce0b82d80f56985ed4","topic":"比手工操作的人工处理时间更少","expanded":true}]}]},{"id":"b43833f75f287baee8d0299271","topic":"多道批","expanded":true,"children":[{"id":"1d2badfb7c68ac2faffba81f9d","topic":"多道、宏观并行、微观串行","expanded":true,"children":[{"id":"2f799a18c86b9a12043d691207","topic":"实现了并发","expanded":true}]}]},{"id":"1079739904cad92bda458bafdf","topic":"缺点：","expanded":true,"children":[{"id":"3cb988ec04f9dfa8bbd4cab386","topic":"不提供人机交互","expanded":true,"children":[{"id":"22fbd0cbc70baf0d5d138bf2fc","topic":"优点：","expanded":true,"children":[{"id":"63db8aded7bb2403b1ce59d29e","topic":"资源利用率高\n更能保持忙碌情况","expanded":true}]}]}]}]},{"id":"861aa5a054eb2bf57a14196c39","topic":"分时操作系统","expanded":true,"children":[{"id":"dd591335da2b764d6ecaaacbc2","topic":"同时性、交互性、独立性、及时性","expanded":true,"children":[{"id":"447abd3f05eace102b836803a5","topic":"独立性：多个用户可以不被干扰的控制计算机","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"795ab5c1186af3f6032579308a","topic":"会浪费一定的资源利用率来完成分时操作","expanded":true,"style":{"background":"#FDD834"}},{"id":"8f189ba2db694d17dedafbdc8b","topic":"缺点：","expanded":true,"children":[{"id":"e58893821a4a64b2a7ef9afcb2","topic":"缺乏对紧急事件的处理能力","expanded":true,"children":[{"id":"f6f846f8ba1940547fffdaed87","topic":"优点：可以人工交互","expanded":true}]}]}]},{"id":"6dcaa3621d299747bc29991409","topic":"实时操作系统","expanded":true,"children":[{"id":"8a09d836243b1d3b968f4a45b4","topic":"硬实时","expanded":true,"children":[{"id":"5b0ab74d9e6aad71845f0abdf8","topic":"某个动作必须提供绝对的保证，在某个特定时间内完成","expanded":true}]},{"id":"1aea4aa1c8c8796bf45c89375d","topic":"软实时","expanded":true,"children":[{"id":"9609ddd23868c8200f93291305","topic":"可以偶尔违背一下时间规定的","expanded":true}]}]},{"id":"6b9b20f1023b634ca9098864d4","topic":"网络操作系统","expanded":true,"children":[{"id":"253bcff01da8e95e9a37aad07d","topic":"网络中的各种资源共享和多台计算机进行通信","expanded":true}]},{"id":"ab394dba8a9bce2540eb9b6ea7","topic":"分布式操作系统","expanded":true,"children":[{"id":"404915d3905adea438d2fb322b","topic":"每台主机都有同等地位，不存在主机从机","expanded":true}]},{"id":"34fa1ba635f9dfc70ff3bbc1ce","topic":"个人计算机操作系统","expanded":true,"children":[{"id":"2a1b17963ba8dc64edf0e8b80f","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f7db496fd320d8.png","width":777.39,"height":263.6}}]},{"id":"af094b9f9e18ac8da522ba8cec","topic":"多任务（现代计算机）操作系统：","expanded":true,"children":[{"id":"7eab34cc12699a1db955191629","topic":"并发 + 并行","expanded":true}]}]},{"id":"7cf9644aaebbdea584badbf14c","topic":"操作系统运行环境","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-127eb26f8b6f75.svg","width":94,"height":94},"children":[{"id":"262ffcee-d346-4a49-8410-c81225f3863d","topic":"处理器运行模式","expanded":true,"children":[{"id":"f43149fe-936b-471b-ac7e-3181c63c5507","topic":"特权指令/非特权指令","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"1022972f-2630-43a0-a797-76c200a53a4b","topic":"特权指令：是指不允许用户直接使用的指令，如I/O指令、置中断指令","expanded":true,"style":{"background":"#8EDE99"}},{"id":"0eb07d2a-881f-45bd-a63f-8be5e5935534","topic":"非特权指令：是指允许用户直接使用的指令，它不能直接访问系统中的软硬件资源，仅限于访问用户的地址空间，这也是为了防止用户程序对系统造成破坏","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"3f68261cf59a42a252c838140d","topic":"内核态和用户态","expanded":true,"children":[{"id":"7c3ab845dcea04b19a32b96ad0","topic":"PSW = 1，即在内核态（管态）","expanded":true},{"id":"20280b9c96a9474a2689d81dbc","topic":"PSW = 0，即在用户态（目态）","expanded":true},{"id":"4d7bd125-80e9-42e1-ae28-6bc66e0fe3f9","topic":"广义指令 = 系统调用","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"29a25f82-2eee-4c56-b7ce-820326e4d49b","topic":"广义指令在用户态下调用，内核态下执行","expanded":true,"style":{"background":"#FF9595"}}]}]}]},{"id":"be38a178d37b7c5950863993ec","topic":"4方面内容：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"ec0a0942a5aaf1bf9cee5b6414","topic":"时钟管理","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"884a70ffe0cad2bf3fa95829a3","topic":"功能：计时、切换进程","expanded":true}]},{"id":"bdcbbd32073a8a5a611d0bafbc","topic":"中断机制","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"75c82b8fed6825916e27f9b3aa","topic":"引入中断提高CPU利用率，提高外部设备利用率","expanded":true}]},{"id":"153a630b63c88bf47c1abad385","topic":"原语","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"caa9344ff1ab10701b0188a9eb","topic":"处于操作系统最底层","expanded":true},{"id":"3f98660b46992b97044769db72","topic":"具有原子性，一气呵成","expanded":true},{"id":"f7292835ff9a92b36bf3e83985","topic":"运行时间短，调用频繁","expanded":true}]},{"id":"32abd6123cf9f81ff3a839a3d4","topic":"系统控制的数据结构和处理","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"3a29c968e58b9c07dbf39b7028","topic":"进程管理","expanded":true},{"id":"08f87d1729fbc65b09cabb39b5","topic":"存储器管理","expanded":true},{"id":"1cca2f9b79eaa19684245af5e0","topic":"设备管理","expanded":true}]}]},{"id":"36c89ed5640938486af2cbe456","topic":"中断和异常","expanded":true,"children":[{"id":"02c80201b438d390d0fd284aef","topic":"中断","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"db4ae5c597fa53c4b987cb58db","topic":"内中断","expanded":true,"children":[{"id":"c790fe5c-4e28-48e7-9b96-b552f923c908","topic":"来自CPU内部的","expanded":true},{"id":"9d2a7ff2be499b282bd5dbaac4","topic":"故障 fault","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"14ec994a-f46b-423c-b289-eb03fbdcbb9c","topic":"fault是可以被修复的异常","expanded":true,"style":{"background":"#FDD834"}},{"id":"24b75d42-c627-4f82-b183-a3563b57d508","topic":"非法操作码、缺页、除数为0、溢出","expanded":true}]},{"id":"8ab808cdfdcbb861f190f98fe8","topic":"自陷 trap","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"9682d158-5296-4e70-a1e4-81396689c21e","topic":"trap指令","expanded":true,"style":{"background":"#FDD834"}},{"id":"f03af47f-1cd7-417b-8076-e58cc19babbf","topic":"安排好的时间，在用户态下调用操作系统内核程序","expanded":true}]},{"id":"b859ccb2e218d898d9b09a0a57","topic":"终止 abort","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"6b935ff1-5a8f-490b-b008-8056465804dc","topic":"abort是十分严重的异常","expanded":true,"style":{"background":"#FDD834"}},{"id":"c0a7eb26-2cbb-496f-a884-57c9fc93b4e0","topic":"使CPU无法执行的硬件故障，例如控制器出错了、存储器校验错等","expanded":true}]}]},{"id":"340bb52a6c5a3a19c5d2dba317","topic":"外中断","expanded":true,"children":[{"id":"b6e9a5e8-b1c1-43ea-aac2-d54fcace2ecc","topic":"通常处理IO","expanded":true},{"id":"ea098d2c7db820b8bcac9bff03","topic":"可屏蔽中断 INTR","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"fb71ca1d-8738-449f-b0d2-69e7bc09900e","topic":"通过改变屏蔽字实现多重中断","expanded":true}]},{"id":"e6895a29f52872e5e6c36b1629","topic":"不可屏蔽中断 NMI","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"a6b3bd5b-fe1e-441b-ba29-894022dbe7e4","topic":"紧急的硬件故障","expanded":true}]}]}]},{"id":"d7a85a6713f85b056c9918a9e6","topic":"中断处理：","expanded":true,"children":[{"id":"02cbb9edeafb412eaf72bad1a5","topic":"OS检测到中断后，就会查询系统中断向量表，找到应该执行的中断处理程序","expanded":true,"children":[{"id":"33cbdc008db8f5723daa9a5025","topic":"通过中断向量地址 --->  中断向量 ---> 处理程序","expanded":true}]}]},{"id":"ffab81d53b1a83523803fa817b","topic":"中断处理过程：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"be8a748f718a13fc2871ea0c7c","topic":"中断隐指令","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"b7ba8db471e965be57626890b2","topic":"1. 关中断","expanded":true},{"id":"263be761b3ab41da266e0aa41e","topic":"2. 保存断点","expanded":true,"children":[{"id":"44480d27c61be873e4c2cb9bc1","topic":"即PC寄存器的内容","expanded":true}]},{"id":"5aa9b936819b2c0aa5b0a9a9ea","topic":"3. 中断服务程序寻址","expanded":true}]},{"id":"2f5a6b5823fabbed30fb7a782b","topic":"中断程序","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"bed8ec692ada273c4ed36a7fc4","topic":"4. 保护现场和屏蔽字","expanded":true,"children":[{"id":"3febb7a338ca96d0b3c86b9f8a","topic":"现场信息：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"c3e8e506052a18537dbc69f647","topic":"PSW程序状态字寄存器","expanded":true,"style":{"background":"#FDD834"}},{"id":"4c4a86045b6805acef32084580","topic":"通用寄存器内容","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"ae2b2850969a2fe879575ae12e","topic":"屏蔽字：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"01abc2f7e909001267adb8a3b1","topic":"硬件实现、软件实现（计组）","expanded":true,"style":{"background":"#FDD834"}}]}]},{"id":"182915d3c128075ba11acbb125","topic":"5. 开中断","expanded":true,"children":[{"id":"9909aae8c529a830c49efb8406","topic":"如果不支持多重中断，则没有这里的开关中断（计组）","expanded":true,"style":{"background":"#7986CB"}}]},{"id":"6ccabec8ac0b61b24d686bc103","topic":"6. 执行中断处理程序","expanded":true},{"id":"2f49b0250748881fb4a82ac7fb","topic":"7. 关中断","expanded":true},{"id":"4eead9ae7e691ac5f1682b439e","topic":"8. 恢复现场屏蔽字","expanded":true},{"id":"623b9a22929b79ad940cda5fe2","topic":"9. 开中断","expanded":true},{"id":"98eb40aaf76a7fa032339b2e81","topic":"10. 中断返回","expanded":true}]}]}]},{"id":"5fa847aafb4bde968cfc89fed0","topic":"系统调用","expanded":true,"children":[{"id":"79fb798cac1a65d8437d096ac6","topic":"系统调用可视为特殊的公共子程序","expanded":true},{"id":"fa1abbbe553937f616b66b38ad","topic":"分为五类","expanded":true,"children":[{"id":"75a1f077-b810-49f1-8c96-a9b700d124de","topic":"设备管理、文件管理、进程控制、进程通信、内存管理","expanded":true}]}]},{"id":"0b0c2d4e-f053-460c-b7be-c2413af03d7e","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"dbbaabdb-de9e-4daa-b179-cde91954035a","topic":"11、12*2、13、14、15*2、16-22","expanded":true}]}]},{"id":"514d0154-c614-46a6-993f-b984b0e5189b","topic":"操作系统结构","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-6feacda3816260.svg","width":94,"height":95},"children":[{"id":"ea06471e-13de-4ee9-b7a4-6ea968403804","topic":"分层法","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b89f9ebc-3631-4e8c-8fc2-1da8c3e56e27","topic":"图示","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ea2ed7abf36eb5.png","width":432,"height":304}},{"id":"c13b6a4f-17c2-4c29-b360-c7079bf75894","topic":"优点","expanded":true,"children":[{"id":"f511d1fe-e523-4681-b94e-d03192331319","topic":"1. 简化了系统设计和实现，编程方便，便于调试 2. 便于扩充和维护","expanded":true}]},{"id":"bf5e91c7-616c-46bc-9689-60eb96ddd619","topic":"缺点","expanded":true,"children":[{"id":"2775ff5c-69f4-46fd-85a2-95fc6c852c34","topic":"1. 定义各层比较困难 2. 效率差","expanded":true}]}]},{"id":"1fd1b7a1-ba62-4d99-8c2e-b549cd74c406","topic":"模块化","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"d1364510-15cd-4657-a3fd-e365d7f1960b","topic":"图示","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-7a9fdbdc370e49.png","width":420,"height":180},"children":[{"id":"2f8068be-4cf0-49d5-bb53-f7466f86fb3d","topic":"分块标准","expanded":true,"children":[{"id":"8148857f-363c-412f-907a-54b2062cbd53","topic":"高内聚低耦合","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-b0292df014f831.png","width":261,"height":134}},{"id":"d3daf3cf-464a-44a9-9ecb-ba50dcebbf3f","topic":"模块内紧密度要高，模块间的联系影响要小","expanded":true}]}]},{"id":"ed9f13b8-5095-4aba-b442-714dc1d6c1c2","topic":"优点","expanded":true,"children":[{"id":"734194ce-d1a3-496d-8a70-79ce3c2a38de","topic":"1. 提高了OS的正确性、可理解性、可维护性 2. 可适应性高 3， 加速的开发过程（可以不同模块不同团队同时开发）","expanded":true}]},{"id":"6b903ab9-5652-4c8b-9cf5-c1a47147a93e","topic":"缺点","expanded":true,"children":[{"id":"d48f8dec-f5db-4caf-8c50-a8785ac16729","topic":"1. 【模块间】的接口规定很难满足对接口的需求 2. 各模块开发者难以找到一个可靠的决定顺序","expanded":true}]}]},{"id":"ee1bb868-f5ce-44ad-b5ec-de600ee01184","topic":"宏内核","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b6a95813-751e-4dc4-bb12-b38fe75f08fc","topic":"单内核、大内核","expanded":true,"style":{"background":"#8EDE99"}},{"id":"a334a572-990e-42f0-954a-139689842995","topic":"OS的所有功能模块全都在内核态","expanded":true},{"id":"90596ab7-5d07-4639-bc48-ed4c9811f45b","topic":"优点：","expanded":true,"children":[{"id":"63022c8f-8bf1-4dd5-bf41-cdffe1ea6cae","topic":"速度快","expanded":true}]},{"id":"b6ce71de-635a-4e81-9b78-9c2086d743bf","topic":"缺点：","expanded":true,"children":[{"id":"2aca6f5e-1c26-4b4e-9764-82b31026e093","topic":"一个模块奔溃导致整个核崩溃","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4e546e09960e57.png","width":384,"height":223}}]},{"id":"e26acd46-4d53-400a-a845-4b86c05ea352","topic":"在桌面OS中宏内核取得很大成功","expanded":true,"children":[{"id":"a73d6ae8-4cdb-406e-b713-ee45d560a1ab","topic":"例如Windows、MacOS、Linux、iOS、Android等等","expanded":true}]}]},{"id":"29fc8e1b-06e1-496f-98df-ef047fc1d196","topic":"微内核","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"9cd76515-c384-4a11-bb6a-323d520edc81","topic":"把部分内核OS代码移出内核，采用C/S模式进行执行","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f42deca9126899.png","width":430,"height":143}},{"id":"25d32c1d-a99e-4347-8c30-7b4f0fde075e","topic":"内核代码：","expanded":true,"children":[{"id":"6c822b27-3e94-4242-bb5e-87e61ee0e19a","topic":"1. 与硬件紧密相连的 2. 一些较为基本的功能 3. 客户服务器的通信功能","expanded":true}]},{"id":"c3cb767e-0893-4d55-8cd7-e82711b6fb9e","topic":"用户的服务器：","expanded":true,"children":[{"id":"0aef1d71-85a7-41e5-a4d2-8ed287fbf7c3","topic":"这些服务器本质上就是一个进程，借助微内核的消息传递机制进行交互的","expanded":true}]},{"id":"554c2243-bc7b-40da-8397-6ad70fa626db","topic":"基本功能：","expanded":true,"children":[{"id":"ac18551c-8035-4c9e-a010-a2d3760314e1","topic":"线程管理、低级存储器管理、中断和陷入处理","expanded":true}]},{"id":"bf8fbee6-5f22-44a7-bda9-c8ca7ee7b150","topic":"优点","expanded":true,"children":[{"id":"a8ae0563-0be6-409e-894a-a544be2fbd9b","topic":"1. 扩展+灵活（新增内容加个服务器就好）","expanded":true},{"id":"3207568a-c858-4d3f-a83f-d3455850e6bf","topic":"2. 可靠+安全（一个模块崩溃就重启那个模块就好）","expanded":true},{"id":"b7b2275b-ef58-4754-b9d7-8b38b2a9ec34","topic":"3. 可移植性好（服务器的具体细节与硬件无关）","expanded":true},{"id":"f6643da8-6ab8-41c5-a793-beab7e2fe19c","topic":"4. 分布式计算，可以很好的支持分布式系统和网络系统","expanded":true}]},{"id":"44426fb2-cd9b-4e46-bf16-5011602c3dc2","topic":"缺点","expanded":true,"children":[{"id":"715b79f8-7c94-4d5e-a549-997eb549541c","topic":"慢","expanded":true}]},{"id":"28aabf54-2709-4d93-9bb7-3f12d960932d","topic":"在实时、工业、军事、航空等特别流行","expanded":true,"children":[{"id":"508ec367-d1f8-40e2-9bc5-8462d33c7f7f","topic":"谷歌的Fuchsia、鸿蒙OS","expanded":true}]}]},{"id":"3251977a-64ea-475b-a1c7-502038e0e124","topic":"外核","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"262a0ab3-a941-4606-9193-1ce7745a429a","topic":"外核是提高'虚拟机’效率的","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"68640414-011d-4554-a360-48dd26727ef9","topic":"外核可以使一个应用进程直接获得访问内核的权利","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"4f46cbef-cc74-46e0-b927-80ed3646096d","topic":"优点","expanded":true,"children":[{"id":"40182461-cb8d-430c-acf0-4eb2e422d166","topic":"1. 减少了映射层","expanded":true,"children":[{"id":"8b0cc3de-2875-4ab7-a586-93afdefcc70e","topic":"磁盘的一个部分的盘块就直接分配给了这个虚拟机，这样虚拟机间就不会发生冲突了","expanded":true},{"id":"350eec34-89d5-485b-a7ec-5299e844e23a","topic":"如果不采用外核：那么多个虚拟机使用同一个内存，每个虚拟机进程需要维护一个映射表格","expanded":true}]},{"id":"425f0cb7-1e28-4c31-bd37-345ddaa118aa","topic":"2. 把多道程序（外核外）与OS代码（用户空间）加以分离","expanded":true}]}]}]},{"id":"c0e0feba-9bc6-456d-be61-61e4ae5557cd","topic":"OS引导","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1a41d00eaed658.svg","width":125.31,"height":127.4},"children":[{"id":"9c53aef8-ebd2-4e06-94e7-802998fef030","topic":"前提","expanded":true,"children":[{"id":"4d513043-bd66-4e35-90f2-eb558e4ddd06","topic":"磁盘的格式化","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"afa0bb82-ef3b-4cf8-b482-8101be94fc2a","topic":"物理格式化","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"e3c644c5-0086-4d1a-9f26-a12a210438ab","topic":"逻辑格式化","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"4b3695a8-7f88-4bef-809f-f048528bca10","topic":"RAM和ROM","expanded":true,"children":[{"id":"93295dbf-2dfc-48bc-aaf5-933575532f32","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-3dd2e0838213d9.png","width":250.15,"height":309.84}}]}]},{"id":"79916a2d-8191-4599-bbb9-63317a5e690e","topic":"步骤图示：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"b622757a-11d1-4c54-ad9e-f05fd852b786","topic":"图示","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-97cdb81ffdb072.png","width":503.16,"height":199.17},"children":[{"id":"b20266d2-a5ed-46b8-b614-3c3a6cbce94b","topic":"MBR中的标志信息位：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"8804bc18-7e78-4358-ba28-45ca6e9d01a3","topic":"告诉主机这个磁盘是不是引导盘（分区中至少有一个分区是活动分区、有操作系统）","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"8b152897-52fc-4799-a2f8-44377ab21ba9","topic":"CPU读ROM进行自检、找OS的","expanded":true,"style":{"background":"#FDD834"}},{"id":"6a25f65d-2cd6-4eed-832f-f483613dc9cb","topic":"引导块：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"1f32e70d-0db9-41ed-b90e-ff05f9762d8e","topic":"如果该磁盘分区有OS，则引导块不为空；如果没有OS，则为引导块内没有实际内容","expanded":true,"style":{"background":"#FDD834"}}]}]}]},{"id":"bf4333bd-3667-43c5-85e6-b6741ef4d7e1","topic":"步骤：","expanded":true,"children":[{"id":"db1869e5-469e-4d27-b8ce-4325f0da2b9b","topic":"① CPU读ROM","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"5fed5117-f105-4164-a98d-d6f38962fc05","topic":"激活CPU","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"1020c72c-8cb3-4257-984b-debaa811a6dc","topic":"CPU读取ROM里的boot程序，IR置为BIOS的第一条指令（开始运行BIOS）","expanded":true}]},{"id":"8641dc84-81e7-4490-a3ad-e613d7ae072d","topic":"硬件自检","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"dfd7d684-73c3-44ed-b87b-87e975fb3dbd","topic":"启动BIOS程序，硬件开始自检，检查是否有故障","expanded":true}]},{"id":"3e4451ac-008a-4db5-9789-a3198e76e7b6","topic":"带有OS的硬盘","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"2e9d9f71-ba92-4579-9032-5eb222e540f5","topic":"BIOS读取Boot Sequence","expanded":true,"children":[{"id":"eb24e13d-927c-48eb-8a42-21432e1036c1","topic":"Boot Sequence是一个在CMOS中的设置启动顺序的元件","expanded":true}]},{"id":"50caa10d-e7c8-4022-9671-52f391c9eabb","topic":"BIOS找到了设置的第一顺序的存储设备，然后把这个设备的【引导扇区内容（MBR）】加载入内存","expanded":true}]}]},{"id":"c5001ff8-ac3f-4a36-922e-a2a6e6738b75","topic":"② RAM读MBR","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"90c2ee0a-4026-4e0f-bbee-b6a7b171ecd4","topic":"加载主引导记录MBR","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"206f2905-0235-4050-9223-7dafc4679c6a","topic":"硬盘以特定标识符来区分引导和非引导盘。遍历每一个，直到发现引导盘","expanded":true,"children":[{"id":"719613ed-4ad8-4944-9507-20424dc13d8b","topic":"MBR作用：告诉CPU去哪个主分区找操作系统","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"8b6e0fcd-1ee6-414f-afec-bebdec2cd646","topic":"加载硬件分区表","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"31aa53eb-2e02-4be5-9e92-95c768faf9b3","topic":"找哪个磁盘分区中装有操作系统，所以需要扫描MBR中的硬件分区表","expanded":true}]}]},{"id":"b6f78f60-b1aa-4d92-bac8-f74472f13f6b","topic":"③ RAM读活动分区","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"221ee5e7-370a-42e9-99b4-cd57081b0636","topic":"加载磁盘活动分区","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c464c917-8c89-4e0a-b5d0-5dd5b96905fb","topic":"活动分区：装有OS的分区就是活动分区","expanded":true},{"id":"9355aee9-492a-4975-a8ab-9c335847cf80","topic":"MBR找到了对应的OS分区后，把这分区读入RAM","expanded":true}]},{"id":"e80dbba5-8149-4977-adb0-e9362c087891","topic":"加载分区引导记录PBR","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"cd33c163-9a34-4ed4-bac8-aa7b587ad25f","topic":"PBR：引导块","expanded":true},{"id":"110b8287-8feb-4ac4-9cae-c05399f184e9","topic":"寻找并激活根目录","expanded":true}]},{"id":"d62ae174-c473-4303-9785-6572536d02dc","topic":"加载启动管理器","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"924c8bed-301a-48fc-81db-a93aefb8d326","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-a361af8957eeb0.png","width":653,"height":366}}]}]},{"id":"7d2ffa48-e06e-47fc-b705-4059e84834f0","topic":"④ RAM读操作系统","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"3d2ab827-cf9c-4246-a2b1-5e1afba62404","topic":"从根目录处加载操作系统","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"908ff787-7378-482f-830a-cca0467b1de3","topic":"例如MAC的boot根目录","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-53547b34967926.png","width":502,"height":310}}]}]}]}]},{"id":"bebfefe0-a411-4265-807c-26dcdcce9284","topic":"虚拟机","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-840402b6aff094.svg","width":123,"height":124},"children":[{"id":"e993aff7-af4b-4ccd-ac2f-f51c14c92992","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"e5808037-491b-404a-9172-9aecd494b33e","topic":"22","expanded":true}]},{"id":"ffe73d6f-864c-470c-9604-b5cae3e09749","topic":"计算环境","expanded":true,"children":[{"id":"2085a4a5-1367-4779-9fa6-ed86e1978628","topic":"逻辑的计算机，通过隐藏特定计算平台来为用户提供抽象、统一、模拟的计算环境","expanded":true}]},{"id":"75c0f104-7dad-4962-9cea-763fccb67fee","topic":"第一类","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"75aa41a5-1bcf-4c87-b485-2f1fab55d44e","topic":"第一类虚拟机是运行在裸机上的OS，它的工作是支持真实硬件的多个虚拟机拷贝，类似于不同操作系统支持的进程。","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"2aa363ef-5405-4da2-9141-675bb0ba5c84","topic":"例如Xen、Hyper-V、vSphere","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-337efa2656c600.png","width":386,"height":252}}]},{"id":"d23a4850-0d99-4858-a3af-52bc01488d8d","topic":"虚拟内核态","expanded":true,"children":[{"id":"8dc69d3a-ebbb-454a-ae93-c2d0ad3a2192","topic":"OS认为自己运行在内核态，但其实不是内核态","expanded":true,"style":{"background":"#FF9595"}},{"id":"01f1e521-495f-491d-b289-050710a2a31c","topic":"OS上的用户进程认为自己执行在用户态，事实也如此","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"cddc2dc6-2ef1-484a-971b-3ae72268bb25","topic":"第二类","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"cbc1e265-9ab4-4f59-b4ff-06d3fec24cb9","topic":"第二类虚拟机是运行在宿主操作系统上的，进程调度、资源分配等是依赖于其他OS的","expanded":true,"children":[{"id":"d1dc3a08-bf5e-4ef4-a121-d3eacaed4a1b","topic":"例如VMware","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f0e077f9167291.png","width":372,"height":360}}]}]}]},{"id":"282a1a55edf9db3e208ecacfbe","topic":"做题遇到的概念","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-54c6bb48937d38.svg","width":109.06,"height":109.06},"children":[{"id":"821b2f489cfbec03a21d29580b","topic":"硬件支持","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"14b9ff74c51ab1ed89dd791aa6","topic":"需要硬件支持","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"602bf064434bf845cff8ba5e48","topic":"地址映射","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"4bd8550f1129f17e45bd7bfa7c","topic":"地址映射需要重定位，需要访问存储单元","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"ee8b4dc0892882c3e2d3a91e39","topic":"时钟管理","expanded":true,"style":{"background":"#FFABD5"}},{"id":"4d2bf7a506f9fe0b94da8aa78f","topic":"中断系统","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"e5e918eededb7d52b3f4c8a0f5","topic":"不需要硬件支持","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"8028bd3604ab515675a6088b0b","topic":"进程调度","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"35294254e07a0b734e4e396d40","topic":"用户态和内核态","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"db294f4eae39de55e9e049ff27","topic":"执行程序or发生情况：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"0df802536cb82e86cb472b6aac","topic":"用户态下","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"1278b89906d8c6f1c83f29806e","topic":"缺页","expanded":true,"style":{"background":"#FFABD5"}},{"id":"12e8e66033faab24e3b63a6b4c","topic":"系统调用","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"4b086df8b628a59a3c426ad1d9","topic":"访管指令","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"9fea9ce9-5f21-49c5-acae-51ea5e01ff82","topic":"广义指令的调用","expanded":true,"style":{"background":"#FFABD5"}},{"id":"8bebd73b32e95cedeeb669142e","topic":"外部中断","expanded":true,"style":{"background":"#FFABD5"}},{"id":"81ebae1052480553aa4789a449","topic":"命令解释程序","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"627bf486191abd57995a298712","topic":"内核态下","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"baaae97ff829c3a303b0a9856b","topic":"进程切换","expanded":true,"style":{"background":"#FFABD5"}},{"id":"d0c96f6022c82164e00779fb50","topic":"缺页处理程序","expanded":true,"style":{"background":"#FFABD5"}},{"id":"485b0081e87abd1b95a64b3015","topic":"进程调度","expanded":true,"style":{"background":"#FFABD5"}},{"id":"7b3bdca5dd4bc121b212aaf3cb","topic":"时钟中断","expanded":true,"style":{"background":"#FFABD5"}},{"id":"25db977f6dba6c8fcdd46bb720","topic":"广义指令的执行","expanded":true,"style":{"background":"#FFABD5"}},{"id":"5348d7bf026ba762c771fbab85","topic":"输入输出","expanded":true,"style":{"background":"#FFABD5"}},{"id":"81681b18af292cead1a1696441","topic":"开关中断","expanded":true,"style":{"background":"#FFABD5"}}]}]}]}]},{"id":"42890592e27838ee2fb1e937f6","topic":"END","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-17250ac514b2bc.svg"}}]},"relations":[{"id":"c619b630ff6972d4a4930802e9","from":"20280b9c96a9474a2689d81dbc","to":"7c3ab845dcea04b19a32b96ad0","bidirectional":false,"label":"是由硬件完成的"}],"summaries":[{"id":"09863ea9-368e-4891-a5e9-5434a8a42d95","parentId":"7df861f92789c992d40a5be279","start":1,"end":1,"label":"单核CPU基本都是并发，多核CPU/多CPU基本都是并行+并发"},{"id":"7dea2f29-b9aa-44e6-9ed4-59e1c431983f","parentId":"4c3be52ff568ef977cbb8b710f","start":0,"end":1,"label":"两个最基本的特征"},{"id":"5bf85f6bddaa9ac20384685577","parentId":"bf89ec3435481989f6a278bd3c","start":5,"end":6,"label":"有点像CS模式和P2P模式"},{"id":"4c70efc4-1c18-4f14-9211-3e5b037385f2","parentId":"db4ae5c597fa53c4b987cb58db","start":1,"end":2,"label":"软件中断"},{"id":"d6dcdbbd-b168-40da-83fd-87b2cc027fad","parentId":"db4ae5c597fa53c4b987cb58db","start":3,"end":3,"label":"硬件中断"},{"id":"dfa9dd96-60bd-4048-a5d4-8369d863ed78","parentId":"ffab81d53b1a83523803fa817b","start":0,"end":1,"label":"结合计组"},{"id":"f5fc20ae-cf73-45b7-9045-aeeb2fbeb74a","parentId":"ee1bb868-f5ce-44ad-b5ec-de600ee01184","start":1,"end":1,"label":"OS服务越来越复杂，OS面临着”软件危机“"},{"id":"df402ed8-36c7-4b29-a20e-33b8643c97fa","parentId":"44426fb2-cd9b-4e46-bf16-5011602c3dc2","start":0,"end":0,"label":"解决办法之一：把用的频繁的服务器加到内核"},{"id":"fe9cc444-25d2-4ca6-acfa-f7b5a991f07f","parentId":"d23a4850-0d99-4858-a3af-52bc01488d8d","start":0,"end":0,"label":"故虚拟机是不允许执行敏感指令的"}],"boundaries":[{"id":"8daa20bd3cbad033942e298857","parentId":"638b72f3456805899832facfb9","start":0,"end":0,"label":"改进"},{"id":"bf8b7f1a87aba887cf6d39385c","parentId":"e58893821a4a64b2a7ef9afcb2","start":0,"end":0,"label":"改进"}]}}},{"id":"193b56735e689ae86a01d91513","topic":"进程管理","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/operating-systems/os-00-sheet2","expanded":false,"maxHeight":260,"doc":{"format":"brushup-mindmap-v1","id":"os-00-sheet2","title":"进程管理","structure":"timeline-h","theme":"auto","root":{"id":"6ceaf460346ab77f696cebc0cf","topic":"进程管理","expanded":true,"children":[{"id":"7c5b0d7d98dbead4990e2890f3","topic":"进程的概念","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-39db04436ae9b5.svg"},"children":[{"id":"cdd57666-11b4-465b-92c2-e3449561284f","topic":"临界资源：","expanded":true,"children":[{"id":"ae362c44-dba8-48cf-b2da-8c6ff6314042","topic":"一次只能由一个进程使用的资源，例如：打印机","expanded":true}]},{"id":"3a4e1165-c8ef-48f8-8632-48bc6e0d825f","topic":"临界区：","expanded":true,"children":[{"id":"c55265db-67b5-49f6-8367-68013767e086","topic":"临界区是一段访问共用资源（例如：共用设备或是共用存储器）的【程序片段】","expanded":true}]},{"id":"6aa9a732c858673cfff0cb689c","topic":"程序与进程","expanded":true,"children":[{"id":"5c794e96dda9073ea57958b7e9","topic":"程序是静态的（就是一段代码块）","expanded":true},{"id":"4b9abf35f4eae8cbcf796b6f57","topic":"进程是动态的","expanded":true,"style":{"background":"#FF9595"}},{"id":"810ba47b9a29390a75188b4a3d","topic":"进程实体是进程某一个时刻的“快照”，静态的","expanded":true}]},{"id":"b6bb593f341ab681d445981782","topic":"PCB","expanded":true,"children":[{"id":"8c9a39ba574a0c156dfbd94c32","topic":"PCB是进程存在的唯一标识（像身份证那样，PID像身份证号）","expanded":true},{"id":"66d8f7e4876bf7fb848ba877ae","topic":"PCB中有【PID + 资源分配清单 + 进程控制/管理信息】","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"aa59cc56-c165-42e6-a65d-68b1b791f1de","topic":"其中UID为---哪一个用户在使用","expanded":true},{"id":"56f9cbe1-dfef-4d12-b5c5-4042f7cddf15","topic":"其中PID为---进程的身份证","expanded":true}]}]},{"id":"3138b1ae1079635c8110593b56","topic":"进程是进程实体的运行过程，是系统进行【资源】分配和调度的基本单位","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"6d5b3059-18d7-4e08-9c05-d692f350fdb3","topic":"线程是CPU调度的最小单位","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"3a98cfc4bc983fe59c3c8be1a6","topic":"进程的特征","expanded":true,"children":[{"id":"6aa8efc9c5682b7f3ac2e9efdd","topic":"动态性","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"2d5bc68d9dbb37d5da1768e53d","topic":"进程是动态地产生、变化和消亡的。动态性是进程的【最基本特征】","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"9ae8594b5fa9fd1bf7756a2253","topic":"并发性","expanded":true,"children":[{"id":"d6898816a30a8e0be5445947c8","topic":"引入进程就是为了使进程可以与其他进程并发执行","expanded":true}]},{"id":"cdfbb9a01308ff6730d0eb67c9","topic":"独立性","expanded":true,"children":[{"id":"616b7b211278945bc00c5b8df4","topic":"进程实体，独立获得资源，独立接受调度","expanded":true}]},{"id":"3de8e5e0d5ba8aa16ea6a9aa6c","topic":"异步性","expanded":true,"children":[{"id":"f87ab0f6-a0ee-4bf5-8e0f-2c1ead600651","topic":"进程间相互制约，具有执行的间断性，进程间以独立的、不可预知的速度向前推进","expanded":true}]},{"id":"feeb65192ef97dcd3e02f9c9f6","topic":"结构性","expanded":true,"children":[{"id":"3d039855-1f00-46bc-99b4-3fd618fe2a3f","topic":"每个进程都配置了一个PCB","expanded":true}]}]},{"id":"0eb495ad-2e6a-4fbc-a501-84cb0b6c88f1","topic":"其他特性","expanded":true,"children":[{"id":"164cf3c0-2f3e-41cd-a78c-31c735379f52","topic":"封闭性","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"7c041c28-c535-4e2d-9dcf-2e26ffd959a4","topic":"进程的运行结果只取决于进程本身，于进程执行的速度无关","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"5305902a-25ca-4ac8-8ee7-a617a9d9fdb0","topic":"进程是【一个】程序在【一个】数据集上运行的过程","expanded":true,"children":[{"id":"3a05d53e-e544-471f-b382-bfffc64250c9","topic":"如果这两个【一个】发生改变，则进程为不同进程","expanded":true}]}]},{"id":"43ba9ddf-1fb0-42c9-b524-6f555592193e","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"9d6681c5-46d4-4b40-ad11-2472da0a49ea","topic":"11、19、20","expanded":true}]}]},{"id":"40bc6e71-6875-4924-b8c9-c4766d956698","topic":"进程操作：","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-84a338e255dc39.svg"},"children":[{"id":"fa0688a7-92f9-4834-888a-eed9be6185d1","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"6aab1e5d-777d-45ba-a7ff-ab7b3ec32570","topic":"10 *2、14、15、18、19、21、22","expanded":true}]},{"id":"efbc3b2d-6e48-494d-a8ca-6399645df6e7","topic":"进程的七状态模型：","expanded":true,"children":[{"id":"ff41abff-0182-41e0-918c-eb920880c50b","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f3c21e8254109a.png","width":414.12,"height":186.99},"children":[{"id":"bb86db13-c289-4bc7-99cd-ceb71274af74","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-342db9da62652c.png","width":384.33,"height":173.92}},{"id":"547b891f-b3fe-430e-b193-46c0fbfd45a6","topic":"由运行结束或者发生异常到终止态：撤销","expanded":true},{"id":"115f1f3b-06ef-4f90-b7dc-274517e5ae9a","topic":"图中还有可能从运行态到就绪挂起（当运行的程序在内存中的空间被抢占后）","expanded":true,"style":{"background":"#FDD834"}},{"id":"dc23a014-2e74-4c3e-82e3-1aad798495d3","topic":"如果在运行过程中自己发生了缺页，那就是到阻塞态","expanded":true}]}]},{"id":"1cd264b9-f199-4db9-8160-c038603de537","topic":"广义狭义的进程调度","expanded":true,"children":[{"id":"8caecb3a-3cdd-45e0-81e8-299a4f18c01e","topic":"狭义的进程调度","expanded":true,"children":[{"id":"85b742ef-070b-4af4-9f96-bd90ec5f4971","topic":"从就绪态到运行态","expanded":true}]},{"id":"d588593f-3063-4f32-a640-24bb767abc94","topic":"狭义的进程切换","expanded":true,"children":[{"id":"76153cd2-f904-4d87-bf37-57a5a7840144","topic":"一个进程从运行态到就绪态，另一个进程从就绪态到运行态","expanded":true}]},{"id":"87a7f2dd-05bc-4c83-975e-f4c65e6631dd","topic":"广义的进程调度","expanded":true,"children":[{"id":"857e1025-9f93-4a00-8d29-2ec314bf7149","topic":"上面两个之和","expanded":true}]}]},{"id":"04ce3443-43a5-49a5-ac8f-832e53dfd0bb","topic":"进程的创建：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"62f96596-b447-4218-b585-38d0af63083d","topic":"内容","expanded":true,"children":[{"id":"ad070947-599e-4f37-9baa-671aad7fa8e5","topic":"创建者为父进程，被创建者为子进程","expanded":true},{"id":"72d2cf13-c9c9-4402-aceb-504b4e9986b8","topic":"终端用户登录系统、作业调度、系统提供服务、打开应用程序都会创建进程","expanded":true}]},{"id":"a5446bee-4ba5-40d8-ada1-96224358b999","topic":"步骤","expanded":true,"children":[{"id":"15fbe892-c57e-49dd-ae02-c2f199ec9b2f","topic":"1. 给新进程分配一个标识符PID，申请一个空白PCB","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"0e9721ce-f70d-4dfc-a6ac-16f21e3b34df","topic":"PCB申请失败，创建失败","expanded":true}]},{"id":"1d9e2c18-e812-4d26-88f8-4f915359484e","topic":"2. 给进程分配内存资源（为程序、数据、用户栈分配必要内存空间）","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"50dd5ff9-6b89-4a57-95a1-1d4077ee3e4e","topic":"资源不足则进入阻塞态","expanded":true}]},{"id":"16ff81f9-9324-435f-943a-aab4f8730352","topic":"3. 初始化PCB","expanded":true,"children":[{"id":"9fbb3e67-5a30-4bc3-839c-074312e062d7","topic":"初始化标识信息","expanded":true},{"id":"06f1b0c8-11eb-4b31-9495-10f11db74569","topic":"初始化处理机控制信息","expanded":true},{"id":"b4911baf-0003-49b6-bd4b-ca06e4d40cc5","topic":"设置进程优先级","expanded":true}]},{"id":"eb161eab-6318-46f8-b00b-7e0cf50a9b65","topic":"4. 待就绪队列可以接纳新进程，将新进程插入就绪队列","expanded":true}]}]},{"id":"7e944c6a-fd08-4565-b8a6-8a398b3d24f2","topic":"进程的终止：","expanded":true,"children":[{"id":"211d72cd-e182-43bd-be2b-b25b037e7d6e","topic":"1. 通过PCB找到该进程的状态","expanded":true},{"id":"c2543c00-2f2e-4f99-b060-cf296555e30b","topic":"2. 终止进程执行","expanded":true},{"id":"9f88b2e6-31a8-489f-89a8-e1ff2a561b2a","topic":"3. 终止所有子孙进程","expanded":true,"style":{"background":"#8EDE99"}},{"id":"2b17bac6-7f62-4178-9ddc-5c74f6f1dc05","topic":"4. 把所有资源都归还给父进程或操作系统","expanded":true,"style":{"background":"#8EDE99"}},{"id":"e0bd49ad-8aec-4556-82f2-7040786a7067","topic":"5. 把PCB删除","expanded":true}]},{"id":"ee99b9c3-e648-454b-8b2d-97a333502d1d","topic":"进程的阻塞：","expanded":true,"children":[{"id":"5ca49af8-64a1-4a8d-8409-99f29600b5c3","topic":"又称：睡眠等待状态","expanded":true,"style":{"background":"#FFABD5"}},{"id":"9af363f5-64c6-4022-80eb-87f0e08f8a46","topic":"1. 找到对应PCB","expanded":true},{"id":"93cc707e-eed3-4d50-8ad5-3253287d6fb5","topic":"2. 若进程在运行态，则保护现场，将其转为阻塞态，停止运行","expanded":true},{"id":"30a2f0df-96ef-4a13-92a8-6fcf6508e14c","topic":"3. PCB插入【相应事件】的等待队列","expanded":true}]},{"id":"5d3c4f08-e9b5-40e2-ab43-2a9c3a06fe93","topic":"进程的唤醒：","expanded":true,"children":[{"id":"0eea8925-104f-4afd-b061-faef972a1e6e","topic":"1. 找到对应PCB","expanded":true},{"id":"9678f93f-7efa-421b-959f-919000434edb","topic":"2. 将其从等待队列中移出，把状态设置为就绪态","expanded":true},{"id":"56c2e179-c4f8-4805-809e-1a6f4b6604dd","topic":"3. PCB插入就绪队列，等待CPU调度","expanded":true},{"id":"b1e79896-7189-4b94-bd61-39f8a713770d","topic":"例子：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"3f556232-18e8-4d0f-9e64-5393bb7c6767","topic":"IO结束","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"fe787281-4551-4194-a67d-de243a0a4b29","topic":"IO结束后，等待这个IO的进程会被唤醒","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"d3f1ff30-a4d8-4b59-b625-91da81a5a03a","topic":"进程退出临界区","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"3d3c11d5-0f93-47c3-b531-c29b9078d370","topic":"进程A想要访问有进程B在访问的的临界区 --- A进入阻塞，进程B访问完临界区 --- A回到就绪","expanded":true,"style":{"background":"#8EDE99"}}]}]}]},{"id":"2c12c333-1c21-402b-a4e4-af0fa3e232e3","topic":"进程的切换：","expanded":true,"children":[{"id":"253a7b25-6072-4826-b3cd-5425da0f1951","topic":"1. 保存CPU环境","expanded":true},{"id":"6b201ab8-ff18-4739-9533-89e1e9179e09","topic":"2. 更新PCB","expanded":true},{"id":"7f0d4bbc-6a4e-4fad-bd6b-da1a4be308d1","topic":"3. 把PCB移入到对应队列","expanded":true},{"id":"a87fa634-6a4c-4598-b8a8-76a76dc70e0e","topic":"4. 更新数据结构","expanded":true},{"id":"4e85c0b1-246a-4235-b178-5bd5fd623cf1","topic":"5. 恢复CPU环境","expanded":true}]}]},{"id":"6cbaef13-ee9a-4d01-aca3-d1b58515ccb1","topic":"进程组织","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-0eb260ceca6ca7.svg"},"children":[{"id":"6e55db4f-0090-4c84-9c65-72db8fd1df36","topic":"进程控制块（PCB）","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"7ab52ad9-11e5-42ad-91ab-a16109cbe8e0","topic":"PCB创建后常驻内存，任意时刻都可以存取，进程结束时删除","expanded":true,"style":{"background":"#8EDE99"}},{"id":"104cf0a3-5af8-424d-a162-02c2abdf1c69","topic":"需要访问PCB的情况","expanded":true,"children":[{"id":"cd831ac4-8678-4a70-a645-b373a5a03c74","topic":"1. OS想要调度某进程运行","expanded":true,"children":[{"id":"4de2e6f4-1adc-4007-b2fc-f4ceef699131","topic":"调度","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"5ca71936-a320-4054-8b00-5f411e575895","topic":"2. 调度到某进程后，根据PCB所保存的处理机状态信息恢复现场","expanded":true,"children":[{"id":"56b2bc24-20cf-45a5-8095-44d8c9997c4b","topic":"恢复","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"0d19ec67-9c3c-492c-a656-64885e443759","topic":"3. 运行过程中，当需要与之合作的进程实现同步、通信时要访问PCB","expanded":true,"children":[{"id":"587042e9-d2c9-4377-94f7-3d012f745baf","topic":"合作","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"7502b730-616b-4dd7-843d-8ac5f3e54400","topic":"4. 进程由于某些原因暂停时，会将其断点处的处理机环境保存在PCB中","expanded":true,"children":[{"id":"fecb68b0-f792-4061-8f19-2f061241b890","topic":"暂停","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"b144219c-56b6-433d-aaa4-e3996c2ac4af","topic":"在整个生命期中，系统总是通过PCB来对进程进行控制，系统唯有通过PCB才能感知进程存在","expanded":true,"style":{"background":"#FF9595"}},{"id":"ac045ac6-8f5a-4d5c-9e25-7d9155c27bd2","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-0e2782bb837dc6.png","width":432,"height":151},"children":[{"id":"37c76e57-ce0c-4463-a106-f9e587f366d7","topic":"1. PID标志各个进程，UID标志进程归属的用户","expanded":true},{"id":"5b41b3e1-aa0c-41d6-90de-82a1e2122ae1","topic":"2. 描述进程的状态信息，描述进程抢占处理机的优先级","expanded":true},{"id":"51739446-1c48-4b97-8c3e-1d44c81a6316","topic":"3. 有关内存地址、虚拟内存地址有关的内容、打开文件列表、IO设备信息","expanded":true},{"id":"702f6567-7e41-4555-bd48-98892411eab7","topic":"4. 处理机中的各种寄存器的值","expanded":true}]},{"id":"6ec18f77-5ba0-478c-8502-df376cc4fbdc","topic":"各进程PCB结构的数据结构","expanded":true,"children":[{"id":"d89cd5e2-c63f-4f4b-bd31-faabe0a0a612","topic":"链接方式","expanded":true,"children":[{"id":"f939a428-ad74-4975-b2d2-b97a95ed23d3","topic":"把不同状态的PCB链接成一个链表","expanded":true}]},{"id":"c9e6761e-8a3e-4023-968b-de4be5ab9793","topic":"索引方式","expanded":true,"children":[{"id":"7c683c8d-42e6-42c1-a94c-f4d751aefcca","topic":"把不同状态的PCB组成一个索引表","expanded":true}]}]}]},{"id":"abe77592-128f-403a-a55b-2638ce72c108","topic":"程序段","expanded":true,"children":[{"id":"a58308eb-5ffa-432b-87d7-846768c86b80","topic":"程序段可以被多个进程共享","expanded":true},{"id":"a5bd1f5f-45b9-4ae0-8660-864a7dda0d85","topic":"多个进程运行同一个程序","expanded":true}]},{"id":"8a8d797b-a99a-40b2-8111-bf83c243a0f8","topic":"数据段","expanded":true,"children":[{"id":"b99baa53-1e1a-4f9c-b8eb-4c7eac2aeaad","topic":"数据段是进程的数据段","expanded":true}]}]},{"id":"2bbfb675-d430-4d7f-be98-585d0a6c4d75","topic":"进程通信：","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1cf9eb8bba2435.svg"},"children":[{"id":"263af04a-2ff9-4c31-adf8-58480c6ea60b","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c0e1dc45-b1ad-405a-bef5-33c3f844c38e","topic":"14","expanded":true}]},{"id":"9ab92bb7-fc9b-4203-a2e0-85e9acb56d8a","topic":"共享存储","expanded":true,"children":[{"id":"5591974f-997c-4569-bd54-a7e83f0b33cd","topic":"通过一块可以直接访问的共享空间，通过对这片空间的读写来实现信息交换","expanded":true,"style":{"background":"#8EDE99"}},{"id":"e73b5711-b22e-44b4-8da1-4967eb1993fe","topic":"低级方式","expanded":true,"children":[{"id":"26b6ed9a-c971-4b3d-be2c-c84caa139975","topic":"基于数据结构","expanded":true}]},{"id":"20a8a6c9-7df2-43a1-ad0d-612aa4805af6","topic":"高级方式","expanded":true,"children":[{"id":"b39be424-2263-42cd-9f99-2ec859c3418e","topic":"基于存储块","expanded":true}]}]},{"id":"8aa89028-957b-4f89-8cf8-95a305756600","topic":"消息传递","expanded":true,"children":[{"id":"2546a8e2-45a2-4fd2-b222-9b066e31b24e","topic":"数据交换以格式化信息为单位，若通信进程无可直接访问的空间，则OS会通过发送原语和接受原语来传递数据","expanded":true,"style":{"background":"#8EDE99"}},{"id":"2ca6a03c-be3f-45cc-abab-84a744b061ae","topic":"直接通信","expanded":true,"children":[{"id":"c59ce7e5-d551-4fb7-985c-7373cc149d88","topic":"通过共享空间（缓冲区，输入输出队列）来进行直接通信","expanded":true}]},{"id":"f0737525-2d53-4099-afac-feecb4b718e6","topic":"间接通信","expanded":true,"children":[{"id":"08bbb190-63e5-47d2-b970-0462291c334c","topic":"把信息发到某个中间实体","expanded":true},{"id":"f42f5b30-c188-4aeb-8a35-ee4173c50a1d","topic":"又称：","expanded":true,"children":[{"id":"240ee82d-e7ac-47c1-a750-3e59e989b99f","topic":"信箱通信、电子邮件系统","expanded":true}]}]}]},{"id":"9a161327-ae78-4cf6-b976-9b78012418f4","topic":"管道通信","expanded":true,"children":[{"id":"4c85aae1-f696-4028-9839-f462a68cc908","topic":"使用pipe文件来进行信息传递，属于半双工通信","expanded":true,"style":{"background":"#8EDE99"}},{"id":"b676e0f5-6906-4908-bfc4-eb09308ad51f","topic":"两个特点：","expanded":true,"children":[{"id":"e53b241e-963d-49db-b1dd-14c284b32416","topic":"1. 管道写满，write()阻塞；管道变空，read()阻塞。","expanded":true},{"id":"7730a0d3-58aa-43ff-ab4f-a5df042f786d","topic":"2. 数据一旦被读出，就会被抛弃，故只能有一个读进程","expanded":true}]}]},{"id":"9d02ab22-325e-4183-bef2-5f51bd471843","topic":"通道、管道、管程","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"8190baca-c6f2-43fd-b2e4-26c2024533f7","topic":"通道：硬件IO技术，用来进行快速的、多个块的IO传输","expanded":true,"children":[{"id":"14742680-4c4f-46c0-a784-5ba1ea02d510","topic":"比DMA牛逼","expanded":true}]},{"id":"060312c8-a732-4f61-a97c-8fe0d1e0d52d","topic":"管道：pipe文件，信息传递用，半双工","expanded":true,"children":[{"id":"ff567c78-04f8-4a08-8c47-8387e29a0b26","topic":"信息传输","expanded":true}]},{"id":"b29ed31f-2d3e-4d02-8943-60177eff362a","topic":"管程：在进程互斥机制中对PV操作进行管理的数据结构","expanded":true,"children":[{"id":"a290c2a4-a5a4-455a-9f21-3a54547ec180","topic":"信号量、PV","expanded":true}]}]}]},{"id":"b5d8bb04-bdd4-48d3-91e4-e516e76f87e3","topic":"线程：","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-599e299f018f2c.svg"},"children":[{"id":"137c33f2-d4dd-4cea-85f5-5e613964c120","topic":"轻量级进程，CPU的最小执行单位","expanded":true,"style":{"background":"#8EDE99"}},{"id":"749d634a-8d1b-44af-81cc-9d6b787024a4","topic":"进程作为CPU外资源的最小调度单位，线程作为CPU的最小调度单位","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"8b8cd200-fad4-426b-90e3-127d614c0555","topic":"也称为程序执行流的最小单元","expanded":true},{"id":"331ca6cb-6c4a-47c5-8cbc-abe4ed2269ce","topic":"进程 --- 资源调度和分派","expanded":true},{"id":"2e6f1144-301d-4129-b03d-758456e1ab59","topic":"线程 --- 处理机调度和分派","expanded":true}]},{"id":"7c4cb057-a3c1-45a5-84ff-3e1dd897b0d6","topic":"进程和线程的区别","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"890024ec-b2fd-4ad8-a313-07b1c7df6000","topic":"1. 进程仍是资源分配的最小单位，线程不拥有系统资源，线程可以访问隶属进程的系统资源","expanded":true,"children":[{"id":"6640291d-46a5-4f29-afb6-ccd5b339c57f","topic":"线程也可以分配资源，但是仅仅是CPU资源的情况","expanded":true}]},{"id":"2edf5bfa-9176-445b-aaff-00a5654ad2c8","topic":"2. 在引入线程的OS中，多进程、多线程都可以并发执行","expanded":true},{"id":"46f05b85-12ed-4bfc-a258-cc4d6e588f13","topic":"3. 创建、撤销、切换进程时都会有较大的消耗，而对于线程就不会有较大的消耗","expanded":true},{"id":"61954204-d777-4e63-9c6d-0ead8f9fe36f","topic":"4. 进程空间相互独立，进程内的线程对其他进程不可见","expanded":true}]},{"id":"1587432f-f485-4827-b435-c0f80fa0ea52","topic":"内核级线程：","expanded":true,"children":[{"id":"c72a7554-f8b1-46a9-b344-1e8428ef4b7f","topic":"只有内核有线程管理的代码","expanded":true}]},{"id":"2d20490b-9f88-4474-a7a8-85a75d242a15","topic":"用户级线程：","expanded":true,"children":[{"id":"32127366-591e-4da1-be90-ff8e8e6c0f5c","topic":"用户自行进行线程管理","expanded":true}]},{"id":"618e43c5-ab67-4ef5-8eaa-922d48daeb7e","topic":"线程实现方式：","expanded":true,"children":[{"id":"e3ad82cf-4b6c-4433-b51b-0dd2a65574da","topic":"OS会给每一个内核线程分配一个TCB（Thread Control Block)","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8ba2f7e1de4532.png","width":584.3,"height":286.5},"children":[{"id":"7d09e930-5bee-4b33-b13c-52c7c281fd5e","topic":"用户级方式","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"0367951a-b68a-445f-a302-77f8553edd34","topic":"用户级线程 ULT","expanded":true,"style":{"background":"#8EDE99"}},{"id":"9856c1c9-67f7-4f16-9df1-5fb660fbb756","topic":"一个系统进程多个用户线程","expanded":true},{"id":"1fc247b9-a64f-4da9-bcab-71b9ed6a7e64","topic":"一个线程被阻塞，整个进程被阻塞","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"653f6186-f53e-4949-a357-7dee85e62958","topic":"内核级方式","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b264328d-9384-425c-81d8-a967613920d8","topic":"内核级线程 KLT","expanded":true,"style":{"background":"#8EDE99"}},{"id":"45ef28b5-6226-40c8-8663-a24b817a5a16","topic":"一个系统进程一个用户线程","expanded":true},{"id":"b3472c58-bc44-4049-aa78-e1dc7c1297d9","topic":"资源浪费大","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"9731635a-910c-4da9-baff-4bfd3c5d2552","topic":"组合方式","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e8128a2c-8dd5-4256-94c3-0c8b40c87692","topic":"组合模式","expanded":true,"style":{"background":"#8EDE99"}},{"id":"5e7b0dec-0cd5-4505-877e-8e819dc203fa","topic":"多个系统进程多个用户线程","expanded":true}]}]}]},{"id":"cbe3e367-0357-4807-acc5-2a2a772c6fb7","topic":"多线程模型：","expanded":true,"children":[{"id":"525ce66c-99de-4924-a74a-76567047d409","topic":"考虑红框部分","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-aa78b3cc025df5.png","width":577.43,"height":290.86},"children":[{"id":"dbea0808-9821-4842-8319-edb13c6308cf","topic":"一对一模型","expanded":true,"children":[{"id":"f6a74465-591b-4d25-98f3-7a367dcc945e","topic":"一个用户级线程","expanded":true,"children":[{"id":"02dd5856-5fa1-4ae2-9fbd-b1c0022df670","topic":"对应","expanded":true,"children":[{"id":"25434aeb-3f2b-4fdd-80a3-f3366da88afd","topic":"一个内核级线程","expanded":true}]}]},{"id":"7390af65-4131-4dc7-a3d7-01fca49abaa4","topic":"优点：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"7694893b-af73-4091-acbc-cce86f992e53","topic":"一个线程阻塞，可以调度另一个线程，并发能力强","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"3eeb3864-f987-4fdd-ad77-d16b2afd1286","topic":"缺点：","expanded":true,"children":[{"id":"0f964685-e965-4912-b549-6894517bde78","topic":"每来一个用户级线程都要创建一个内核级线程","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"855f1f24-89f8-4b98-b941-79c223895708","topic":"开销大","expanded":true,"style":{"background":"#FDD834"}}]}]}]},{"id":"bbc0c9cd-77cf-40cd-a13c-31abb53ec3a2","topic":"多对一模型","expanded":true,"children":[{"id":"a6194637-f88c-431e-9c47-52325c8c4f93","topic":"多个用户级线程","expanded":true,"children":[{"id":"51e19291-73c8-4f07-86c1-a2d3a2f8b8f0","topic":"对应","expanded":true,"children":[{"id":"803f2660-4d7a-4e78-9990-eeb5344a3ebf","topic":"一个内核级线程","expanded":true}]}]},{"id":"60fcfcbe-60b8-4149-b7e2-b87361c04c3d","topic":"优点：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"21c7e1a6-217e-4d73-905d-ae96019d14cb","topic":"线程管理在用户空间，效率高","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"48ac7b8f-5768-4509-ac87-a91668d9a7ff","topic":"缺点：","expanded":true,"children":[{"id":"cf7bd1f4-6ccf-4fc8-99cd-748ef51f6849","topic":"一个线程阻塞，整个进程阻塞","expanded":true,"style":{"background":"#FF9595"}},{"id":"714aad58-b29f-4908-aacb-da8e62aecf36","topic":"每个进程同时只能有一个线程访问内核","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"250c6aa2-6c37-41af-9ed6-197ad1a34879","topic":"并发度不高","expanded":true,"style":{"background":"#FDD834"}}]}]}]},{"id":"9bbef0a4-916f-468a-8e7c-9d7dc3970bb0","topic":"多对多模型","expanded":true,"children":[{"id":"5c32009d-8aed-4c7e-8682-fd9894e95d90","topic":"多个用户级线程","expanded":true,"children":[{"id":"a199462e-5a4f-49bd-b3fb-0764492fb4ae","topic":"对应","expanded":true,"children":[{"id":"a0cb60e8-131e-4765-98da-e98155bed287","topic":"多个内核级线程","expanded":true}]}]},{"id":"6194818e-a27e-4744-b325-76fc0cf4282e","topic":"优点：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"cd98be89-9014-4c9e-9d0f-d3e9f4c3977b","topic":"解决1:1的开销大和N:1的并发度不高，又有他们的优点。","expanded":true,"style":{"background":"#8EDE99"}}]}]}]}]}]},{"id":"13764fd6-31e0-4db9-938c-dde2c674a8ef","topic":"进程与线程","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-90bba86bbcf875.svg","width":67,"height":68},"children":[{"id":"0f326e70-6fc3-42e5-b115-44c4cd788057","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"b3200256-a2cd-4c4d-abe3-fc380b99063a","topic":"12","expanded":true}]},{"id":"fdfab801-34cc-4244-adce-95b2890c8b66","topic":"线程的状态和转换","expanded":true,"children":[{"id":"c1b93b95-74b9-442c-8c86-9ad685c24412","topic":"线程三状态模型","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-443a963285f627.png","width":377,"height":229}}]},{"id":"29cca8aa-84e7-49e6-a591-944a1f9c8299","topic":"线程库","expanded":true,"children":[{"id":"bfb0c226-3711-49f0-9d01-6cb606851304","topic":"线程的实现","expanded":true,"children":[{"id":"faad35e9-e4ee-4b54-a9fd-d705fb97c77f","topic":"常见线程库（Thread Library）：例如POSIX标准的Pthreads线程库","expanded":true},{"id":"10fef965-ec1b-4898-9864-f315876089e0","topic":"通过调用线程库提供的函数来创建用户线程，线程的控制（状态转换）由运行时系统负责","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-24eed827315828.png","width":404,"height":327},"children":[{"id":"a6bebf79-3deb-408d-8418-dc99df7fec3b","topic":"通过系统调用来创建内核线程，线程的控制（状态转换）由内核负责","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8bca1fa458963c.png","width":392,"height":330},"children":[{"id":"e472f662-eb30-42b9-a322-dfffeffa1d94","topic":"用户级线程","expanded":true,"children":[{"id":"71eeef6a-7cbf-4bfa-8f16-b24533c547de","topic":"由内核维护PCB进程表","expanded":true},{"id":"faf4663b-ad4d-49ad-82a4-b15356a12a62","topic":"由线程库来实现进程中的TCB线程表","expanded":true}]},{"id":"220f8c5e-7f61-446a-b7e7-77916204b215","topic":"内核级线程","expanded":true,"children":[{"id":"71b783c8-c9d0-4fc8-9ccf-5b3bf7e5535c","topic":"不论PCB还是TCB都是内核进行维护","expanded":true}]}]}]}]}]},{"id":"d0aba946-b654-4d1e-8cf7-5cea700e0779","topic":"线程的组织与控制","expanded":true,"children":[{"id":"3fff5d97-7abb-4302-9e95-f94c62cc60e8","topic":"线程表","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-fd4cff102d3508.png"},"children":[{"id":"406b64ab-3a5d-4637-964a-68bcdcc2f4d1","topic":"TCB","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-7475391c437fae.png","width":448,"height":245},"children":[{"id":"49e8d1ab-594c-4f6c-9ac7-057e6ce9b1bc","topic":"PC：每个线程共享一个进程代码片段，所以需要保存自己的PC","expanded":true},{"id":"4d087f17-5e0d-4382-939b-f4bcfa67e265","topic":"其他寄存器、堆栈指针：同理","expanded":true}]}]}]},{"id":"8724a45a-8af8-4bc3-95c9-a3bc723bda70","topic":"调度器/调度程序","expanded":true,"children":[{"id":"57733672-fa9f-47cc-89e4-a36f11c6baba","topic":"区别在于是否支持内核级线程","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-6e1d322e5b6468.png","width":302,"height":253}}]},{"id":"cd0e3127-9216-426a-bdbd-34365d78f55a","topic":"闲逛进程","expanded":true,"children":[{"id":"0a0e11cb-4500-409e-8f80-cd73082a547b","topic":"idle进程，在系统中没有其他进程的时候运行idle进程，每个指令周期只需进行中断检查就行","expanded":true,"children":[{"id":"49fcdbe9-c525-4f41-a98b-3fc74b3549da","topic":"idle进程的优先级最低","expanded":true},{"id":"03d3f310-3584-46ae-ab67-ccca195a142c","topic":"任何进程进来都可以抢占idle进程的时间片","expanded":true}]}]},{"id":"71cfbee6-8a4e-404a-aec8-f5edc4e1f64d","topic":"内核和用户级线程调度","expanded":true,"children":[{"id":"b6b6adda-9078-4771-ad36-fe0d44b1b9ae","topic":"用户级线程的调度","expanded":true,"children":[{"id":"37f192ea-9883-4a81-b2ad-7eaf63497cc1","topic":"线程切换代价：低，不需要切换完整的上下文\n并发/并行度：低，一个阻塞整个进程阻塞","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ebd6926c96aa82.png","width":333,"height":250},"children":[{"id":"e9a2455a-1724-4f8e-9a01-3e5b57210034","topic":"用户级线程","expanded":true,"children":[{"id":"38c37b83-9025-4cda-8170-abbe465a1478","topic":"内核不知道线程的存在，所以内核是调度进程","expanded":true},{"id":"45e8f4c7-5e43-4fca-a9f1-54acc71a2a9c","topic":"优点：","expanded":true,"children":[{"id":"e0233935-beed-44e6-923f-43e99fba7994","topic":"线程在用户态切换","expanded":true},{"id":"96c02fca-5398-4342-990a-f72388c7b789","topic":"进程可以根据自身需求选择不同算法\n方便在不同系统上实现","expanded":true}]},{"id":"d7eaac19-7141-4387-bd19-992fe7479bce","topic":"缺点：","expanded":true,"children":[{"id":"fcd915de-f84b-4e6e-97e3-a6a7800e6c3d","topic":"进程中的一个线程阻塞了整个进程也会阻塞","expanded":true},{"id":"bb7dfa42-ea43-4a0c-aab3-da37eb46e172","topic":"如果是多处理器，那么无法发挥其并行优势（例如一个进程8个线程）","expanded":true}]}]}]}]},{"id":"e5c592f0-24b4-4c6d-baa1-8d0aba5da185","topic":"内核级线程的调度","expanded":true,"children":[{"id":"579c32a2-ce35-419b-bad3-7c807d23b61c","topic":"线程切换的代价：高，需转为内核态、切换完整上下文\n并发/并行度：高，一个阻塞其他线程仍可运行","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1174d283045939.png","width":342,"height":301},"children":[{"id":"cb96f2be-73c7-46fb-b159-d9fcef798a90","topic":"内核级线程","expanded":true,"children":[{"id":"c7138e69-e9e0-4066-bc79-05ccd42afb61","topic":"内核选择线程进行运行，不用考虑属于哪一个进程，调度线程","expanded":true},{"id":"e051d8af-6747-42b0-9c82-dffa8548d839","topic":"优点：","expanded":true,"children":[{"id":"8d74807b-ad92-441b-9655-f620d74b4030","topic":"多处理器，内核调度同个进程的多个线程","expanded":true},{"id":"50ad2c61-7029-4367-8336-255fae0c76a8","topic":"进程的一个线程被阻塞，内核可以调度该进程的其他线程","expanded":true},{"id":"bfc5e561-64f0-4e8f-92aa-ecfe0377649c","topic":"内核进程自己本身也可以采用多线程技术","expanded":true}]},{"id":"af9a0c52-fce1-4054-9ade-358ae726726c","topic":"缺点：","expanded":true,"children":[{"id":"aeaac4ec-899f-4dca-90e6-71394839b5bb","topic":"性能低，有若干数量级的延迟","expanded":true}]}]}]}]}]},{"id":"bb4f0743-a674-4c94-a99a-ca08f208e23f","topic":"上下文及其切换机制","expanded":true,"children":[{"id":"7a833d49-9cd2-4074-a357-e3cfd34cf713","topic":"进程/内核级线程的切换：","expanded":true,"children":[{"id":"c644e078-c9aa-4445-8850-1134a1083b8a","topic":"1. 保存CPU环境","expanded":true},{"id":"d5cfdbeb-2b91-447d-b271-163efaa0d15d","topic":"2. 更新TCB","expanded":true},{"id":"99a8e75b-fae8-4f92-b3b8-eae2aee5561f","topic":"3. 把TCB移入到对应队列","expanded":true},{"id":"27257b51-7c37-4b80-b157-1b85bfb7a4fb","topic":"4. 更新数据结构","expanded":true},{"id":"dfbfcca2-d3ca-44e1-b472-61ebf474fc2c","topic":"5. 恢复CPU环境","expanded":true}]}]}]},{"id":"d940db56-284c-4ef3-a2f8-7615b909d114","topic":"处理机调度","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-db0daa8f0729bd.svg"},"children":[{"id":"d48e0504-c107-4b17-82dd-a510a437994a","topic":"处理机调度是多道程序操作系统的基础","expanded":true,"style":{"background":"#FF9595"}},{"id":"7c74e543-cbe5-4acc-bc4f-2325df5cf3b6","topic":"三种调度：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"09005337-26e6-4a42-a7e0-1d52f1464772","topic":"作业调度","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b515d34c-cdd7-428b-bff9-bcacfc91b2ef","topic":"高级调度","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"8bed9cbe-a1c0-46f7-a5f1-063c769b359d","topic":"把外存上处于后备状态的作业中挑选一个，给他们分配内存、输入/输出设备等资源，并建立相应的进程","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"24525b4e-953f-4f17-bccd-cf5c555894e3","topic":"外存 -> 内存","expanded":true,"style":{"background":"#FF9595"}},{"id":"62896dcf-18d6-414b-8fbb-b3939578b783","topic":"调度的频率低，一般几分钟一次","expanded":true}]},{"id":"0e5462ea-d07c-45b6-b644-0fded5828812","topic":"内存调度","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"68d33468-7769-4d76-927b-20546a7810ef","topic":"中级调度","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"022d4473-a600-44e5-8187-1d383c629bf1","topic":"把暂时无法执行的进程放到【外存的挂起队列中】，但是其PCB亦然保留在内存","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"45aabca2-a0ef-44b7-8245-65bc760e481f","topic":"挂起态 -> 内存 / 内存 -> 挂起态","expanded":true,"style":{"background":"#FF9595"}},{"id":"975261c6-2d9d-40eb-968a-14cc960bb6a6","topic":"例如：","expanded":true,"children":[{"id":"011fc6d7-dbf2-4909-99ac-2a6bcba70d82","topic":"进程在内存中，出现了其他进程来抢占内存资源，导致进程被移出内存，就会变成挂起态","expanded":true},{"id":"35f8899c-f95b-4d04-9ee8-538f43c02f80","topic":"内存有了空间，就会把挂起态中的进程调入内存","expanded":true}]}]},{"id":"1bfa7fdd-feb2-456e-b514-0d884d2e10d2","topic":"进程调度","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"7ddfe5ea-100b-4431-87ed-d7597e7d2a9d","topic":"低级调度","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"656910da-619b-41c0-b6ea-4e71479966f4","topic":"按照某种方法和策略从【就绪队列】中选一个进程，将处理机分配给它","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"5aadadfd-3cbf-4221-b2c1-ee829ea1c6d7","topic":"内存 -> CPU","expanded":true,"style":{"background":"#FF9595"}},{"id":"f2920b64-ce18-40fc-88e2-151d70a27b62","topic":"频率高，几十ms一次","expanded":true}]},{"id":"4b4929f5-fe11-498b-a669-94f6de89c6c6","topic":"三种调度的联系：","expanded":true,"children":[{"id":"8dfb45eb-8c95-4456-9f8d-6c0678a77f04","topic":"【进程调度】使进程正常活动起来","expanded":true,"style":{"color":"#EEEEEE","background":"#7986CB"}},{"id":"23066d59-8d87-4f8c-8011-b57edcad7d3d","topic":"【作业调度】为进程活动做准备","expanded":true},{"id":"9a128715-7ac7-4d51-9c65-b65a2c73ba7e","topic":"【中级调度】将暂时不能运行的进程挂起","expanded":true}]}]},{"id":"582d0cf1-9167-4fd7-af75-182e4122906a","topic":"调度的时机、切换、过程","expanded":true,"children":[{"id":"72b5a438-20d4-4347-ae73-4ae15f876c88","topic":"什么时候不可调度","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"bb480bd2-9251-43a9-9549-0e5c8623ecc8","topic":"处理中断","expanded":true,"children":[{"id":"abc2867b-1562-462c-bb83-f271ca1b99e3","topic":"多重中断中间可以调度","expanded":true}]},{"id":"3d79f212-9dec-43fc-8eb6-71add89ea4eb","topic":"进程在内核程序临界区","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"6f790872-bb73-49dc-9769-a9c91bc0af92","topic":"因为临界区只能有一个进程访问，所以访问时一定要加锁。解锁前不应切换到其他进程运行，以加快共享数据的释放","expanded":true}]},{"id":"98844e1e-514c-4c86-b8da-57e12c350547","topic":"完全屏蔽中断的原子操作","expanded":true}]},{"id":"b3d21a65-ac4c-4160-a86a-af21b30cfeea","topic":"什么时候可以调度","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"10a727f9-ffa5-41e4-899d-3822ffa9e532","topic":"进程处在非内核程序临界区","expanded":true},{"id":"84ed98bb-6bbe-45cd-83da-e6e3d69c03fa","topic":"发生了引起调度条件且当前进程无法运行下去时","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"9c0e98da-c6d8-4d9f-90a2-64e8f6b7b14c","topic":"可以马上进行调度和切换","expanded":true},{"id":"5c525fb0-eaf7-4b06-8c0e-14b48f81c3a1","topic":"为非剥夺方式","expanded":true}]},{"id":"7b1e4ed4-1076-4883-955e-d15bdcb5d4fd","topic":"中断处理结束/trap处理结束，返回前请求调度，可以马上进行进程调度切换","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"82a96e4a-c124-47ce-9c91-715dd543af22","topic":"剥夺方式","expanded":true}]}]}]},{"id":"b1007e5a-1039-47c7-b45a-c953b740aeac","topic":"调度基本准则","expanded":true,"children":[{"id":"6e2e7d8d-7973-4274-8a22-c3e8024eda38","topic":"CPU利用率","expanded":true},{"id":"30961b3a-197e-45b0-b8e7-8cca0f121280","topic":"系统吞吐量","expanded":true},{"id":"4dd4aafb-c114-4fdd-b2bc-766897b409b8","topic":"周转时间","expanded":true,"children":[{"id":"d23511c4-11ac-4808-8642-f424c3218efd","topic":"周转时间：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"ce018629-f619-42cb-8dfd-9193d50b6d58","topic":"","expanded":true,"note":"$$ t_{周转} = t_{完成} - t_{提交} $$","style":{"background":"#FDD834"},"formula":{"tex":"t_{\\text{周转}} = t_{\\text{完成}} - t_{\\text{提交}}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><msub><mi>t</mi><mtext>周转</mtext></msub><mo>=</mo><msub><mi>t</mi><mtext>完成</mtext></msub><mo>−</mo><msub><mi>t</mi><mtext>提交</mtext></msub></mrow><annotation encoding=\"application/x-tex\">t_{\\text{周转}} = t_{\\text{完成}} - t_{\\text{提交}}</annotation></semantics></math></span>"}}]},{"id":"06095d94-38a3-439b-b483-e3d1b153d3a4","topic":"平均周转时间：","expanded":true,"children":[{"id":"d624dbf6-0809-4c84-b396-c56ec0ee86c4","topic":"","expanded":true,"note":"$$ t_{平均周转} = \\frac{\\sum t_{周转}}{n} $$","formula":{"tex":"t_{\\text{平均周转}} = \\frac{\\sum t_{\\text{周转}}}{n}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><msub><mi>t</mi><mtext>平均周转</mtext></msub><mo>=</mo><mfrac><mrow><mo>∑</mo><msub><mi>t</mi><mtext>周转</mtext></msub></mrow><mi>n</mi></mfrac></mrow><annotation encoding=\"application/x-tex\">t_{\\text{平均周转}} = \\frac{\\sum t_{\\text{周转}}}{n}</annotation></semantics></math></span>"}}]},{"id":"5d1635d2-0b45-44c0-9699-89262202e353","topic":"带权周转时间：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"b414a3c9-b07e-443b-b080-1489b5063d51","topic":"","expanded":true,"note":"$$ t_{带权周转} = \\frac{t_{周转}}{t_{实际运行}} $$","style":{"background":"#FDD834"},"children":[{"id":"6874f30b-b0ed-4819-8fa5-562ce38bfd8b","topic":"带权周转 >= 1.0","expanded":true}],"formula":{"tex":"t_{\\text{带权周转}} = \\frac{t_{\\text{周转}}}{t_{\\text{实际运行}}}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><msub><mi>t</mi><mtext>带权周转</mtext></msub><mo>=</mo><mfrac><msub><mi>t</mi><mtext>周转</mtext></msub><msub><mi>t</mi><mtext>实际运行</mtext></msub></mfrac></mrow><annotation encoding=\"application/x-tex\">t_{\\text{带权周转}} = \\frac{t_{\\text{周转}}}{t_{\\text{实际运行}}}</annotation></semantics></math></span>"}}]},{"id":"61c9166f-ac2a-4bbe-bcf1-327109d34412","topic":"平均带权周转时间：","expanded":true,"children":[{"id":"c56f9ae4-e736-41da-90a7-bd50f2b69602","topic":"","expanded":true,"note":"$$ t_{平均带权周转} = \\frac{\\sum t_{带权周转}}{n} $$","formula":{"tex":"t_{\\text{平均带权周转}} = \\frac{\\sum t_{\\text{带权周转}}}{n}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><msub><mi>t</mi><mtext>平均带权周转</mtext></msub><mo>=</mo><mfrac><mrow><mo>∑</mo><msub><mi>t</mi><mtext>带权周转</mtext></msub></mrow><mi>n</mi></mfrac></mrow><annotation encoding=\"application/x-tex\">t_{\\text{平均带权周转}} = \\frac{\\sum t_{\\text{带权周转}}}{n}</annotation></semantics></math></span>"}}]}]},{"id":"1602a086-023e-49e8-8af6-0ee0da6ed890","topic":"等待时间","expanded":true,"children":[{"id":"8d209309-4a8c-496e-982d-e4fb71999a6c","topic":"等待处理机状态的时间之和","expanded":true}]},{"id":"30cc92bb-96a3-4230-ab33-b12f57a13f9a","topic":"响应时间","expanded":true,"children":[{"id":"9bfd9b22-7505-48eb-807b-6565f518896e","topic":"从用户提交到系统首次产生响应所用的时间","expanded":true}]}]},{"id":"547950c5-814d-48ab-b968-e89a6607d38b","topic":"调度的实现","expanded":true,"children":[{"id":"b511c957-f0ab-4beb-acac-b898b9d0299c","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-499649a4fba16c.png","width":355,"height":171},"children":[{"id":"1f7b764c-4dd2-4905-8a27-3db06b9bb603","topic":"排队器：","expanded":true,"children":[{"id":"292609f6-e73d-4178-bb12-d26fa2fe130b","topic":"将系统中的所有就绪进程按照一定的策略排成一个或多个队列，以便于调度程序选择。","expanded":true},{"id":"ae10e2e6-42d2-4349-b7c6-afcce388a27f","topic":"（变为就绪态就插入到就绪队列中）","expanded":true}]},{"id":"319d9216-c1ca-4d7b-ab49-89530a827d81","topic":"分派器：","expanded":true,"children":[{"id":"9dba709f-1b58-447c-86d1-3b351a2835cc","topic":"调度程序选择进程，分派器从就绪队列中取出","expanded":true}]},{"id":"f04a3522-1c53-4d38-a7ce-ccf3ba7b8447","topic":"上下文切换器：","expanded":true,"children":[{"id":"8fb02015-20ac-47ce-8191-c18022ac14e9","topic":"1. 将当前进程的上下文保存到其PCB中，再装入分派程序的上下文，以便分派程序运行","expanded":true},{"id":"a7129770-ec8c-4223-9894-41a0c3027f04","topic":"2. 移出分派程序的上下文，将新选进程的CPU现场信息装入处理机的各个相应寄存器","expanded":true}]}]}]},{"id":"0b835364-887d-4322-9010-4c8802a5daef","topic":"调度算法：","expanded":true,"children":[{"id":"dcd5c7d3-63e1-4de5-b496-80787481d35b","topic":"FCFS","expanded":true,"children":[{"id":"115be065-b533-44b6-b581-f157c29b533b","topic":"先来先服务","expanded":true,"children":[{"id":"f1051304-fae1-49ec-9caf-2a3612a2f687","topic":"FIFO队列","expanded":true}]},{"id":"197b4e09-bdde-49c2-8421-07a6cd8a5db4","topic":"有利于CPU繁忙型，不利于IO繁忙型","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"d4b1ca85-4f38-45ea-afef-4eb4ed2d2b83","topic":"SJF","expanded":true,"children":[{"id":"a8a26970-06e1-4e6d-8cc2-649c84920d8e","topic":"短作业优先","expanded":true},{"id":"c4b90a08-9be3-4467-9aef-d8464b0642aa","topic":"饥饿，对长作业不利","expanded":true,"style":{"background":"#8EDE99"}},{"id":"752ba47d-d568-424b-bd59-3ccf8b8a6de0","topic":"通过计算得出的进程所需的时间，不一定准确","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"ae44e379-94d2-46d6-b868-cc7a8f9a177e","topic":"优先级：","expanded":true,"children":[{"id":"131b4fef-9e9d-44b0-8bdd-025b0e5dc67d","topic":"剥夺式/非剥夺式","expanded":true},{"id":"af27eef6-610c-4ee2-8ddf-ce50a2e07cf5","topic":"静态优先级/动态优先级","expanded":true,"children":[{"id":"2c11e5b9-2734-438c-a34f-cdb904e2cc86","topic":"静态：","expanded":true,"children":[{"id":"cb9dfb39-12c5-4002-bf28-007c2cd9f494","topic":"创建进程时确定的","expanded":true}]},{"id":"575f7956-5f75-4386-bb4c-df2817458eb9","topic":"动态：","expanded":true,"children":[{"id":"2dd3a6f2-8bed-40b8-abf0-9ebc6a41b63d","topic":"运行时确定的","expanded":true}]}]},{"id":"2a01e81e-ec13-4eef-8689-4a08a0d64658","topic":"优先级：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"de8958b0-ec9a-4aec-a1b6-ea63ce795dab","topic":"系统 > 用户","expanded":true,"style":{"background":"#8EDE99"}},{"id":"95168342-c270-40d1-abe3-5d4319dfe8cc","topic":"交互 > 非交互","expanded":true,"style":{"background":"#8EDE99"}},{"id":"90c1e39f-e348-4d92-b932-9f2b1b3defd3","topic":"I/O > 计算","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"f162793e-f2bf-4c9d-92de-b8f5b7a76c6e","topic":"高响应比：","expanded":true,"children":[{"id":"1442c3f5-4ba0-473d-9d6e-affa832ef23c","topic":"响应比越高，优先级越高","expanded":true,"note":"$$ 响应比R_p = \\frac{t_{等待} + t_{要求服务}}{t_{要求服务}} $$","children":[{"id":"08c73e94-0cac-43f7-8abc-f859c14fca8a","topic":"永远 > 1","expanded":true}],"formula":{"tex":"\\text{响应比 } R_p = \\frac{t_{\\text{等待}} + t_{\\text{要求服务}}}{t_{\\text{要求服务}}}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mtext>响应比 </mtext><msub><mi>R</mi><mi>p</mi></msub><mo>=</mo><mfrac><mrow><msub><mi>t</mi><mtext>等待</mtext></msub><mo>+</mo><msub><mi>t</mi><mtext>要求服务</mtext></msub></mrow><msub><mi>t</mi><mtext>要求服务</mtext></msub></mfrac></mrow><annotation encoding=\"application/x-tex\">\\text{响应比 } R_p = \\frac{t_{\\text{等待}} + t_{\\text{要求服务}}}{t_{\\text{要求服务}}}</annotation></semantics></math></span>"}}]},{"id":"ecd7b0f5-dd71-4db7-8e9e-f1689aaa3f83","topic":"时间片轮转：","expanded":true,"children":[{"id":"c3dd9542-b190-49d7-87da-bb5d73d9141d","topic":"一个进程时间片到了就换一个进程运行","expanded":true},{"id":"43f8864c-f1ad-4e1d-92c7-79d25e498c2a","topic":"目的：","expanded":true,"children":[{"id":"9b4a9e23-3882-4647-bfdc-0319c3a25472","topic":"创造【实时系统】，让多个用户可以及时干预系统","expanded":true}]}]},{"id":"ae1e95a2-da4a-43a9-bfe0-caa84246d656","topic":"多级队列调度：","expanded":true,"children":[{"id":"66dafdca-dcfc-4e5f-b604-e2f27eef5a62","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-450c9b02cf17a9.png","width":336,"height":174},"children":[{"id":"70eaab90-7d72-4b76-be63-6626ec64667e","topic":"把进程就绪队列从一个拆分为多个（根据进程的性质）","expanded":true},{"id":"493cb746-6eb7-4634-8376-010c7b07853b","topic":"多个就绪队列都一定的优先级","expanded":true},{"id":"a9c925d0-f6fc-4616-a8b9-f6da6ac942c3","topic":"不同就绪队列的调度算法可以不一样","expanded":true}]}]},{"id":"b61f10ab-c0b4-4730-b67d-2c55f0cf4654","topic":"多级反馈队列：","expanded":true,"children":[{"id":"bb4bfd14-36ae-4da8-b7b7-aa2e5ed8de08","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-64f9f9bffb8499.png","width":408,"height":168},"children":[{"id":"ae36bbd1-d0f2-42ec-a004-47edecd8b659","topic":"1）设置多个就绪队列，不同队列优先级不同，时间片也不同。","expanded":true},{"id":"10e23742-8bf6-4f1d-8e82-f07316a5528b","topic":"2）除了最后一个队列是FCFS + RR，其他都是FCFS","expanded":true},{"id":"fc895498-15a0-4688-bebf-08e08b36c8f1","topic":"3）按队列优先级调度。","expanded":true}]}]},{"id":"94fc431f-d6b1-44fc-add8-3d6baafbdd67","topic":"比较表格：","expanded":true,"children":[{"id":"dfd70208-387a-438c-a975-f60335a91319","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c3e1188ed5a68e.png","width":439.52,"height":188.14}}]}]},{"id":"ec107fb3-1360-4f7a-bb56-3d02e4836ad9","topic":"考频：超高","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"5e0f1e0c-5847-49b7-988b-650996c9db2d","topic":"09、11、12*2、13、14、16、17*2、18-20、21*2、22、16大","expanded":true}]}]},{"id":"fd1b86ae-8ccd-4c11-9bfe-e3e47cea9967","topic":"同步与互斥","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4f8c7901378046.svg"},"children":[{"id":"4666586a-ea6d-4803-9d50-feb1abaec6fd","topic":"同步的基本概念","expanded":true,"children":[{"id":"15bccd54-ca09-489c-a17d-df1263737fd7","topic":"临界资源：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"1ca328b1-6284-4e49-8542-923979ed5f30","topic":"一次只能有一个进程所用的资源","expanded":true,"style":{"background":"#FF9595"}},{"id":"c7f64deb-479c-43fa-8c2c-fa54cd629d44","topic":"访问过程","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"2913ab6c-9c69-44f2-bc27-e7c4b1eae788","topic":"进入区","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"ab04f157-33b4-4ac3-beb4-cde38c2cb6ec","topic":"上锁","expanded":true}]},{"id":"379b28f9-cb5b-4d78-aeb4-d5b4e2cc8219","topic":"临界区、\n临界(代码)段","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"3cc88e69-7ffa-4afc-92e9-71e9e081f83a","topic":"进程中访问临界资源的那一段代码","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"8c0b7ecf-af7b-4e19-8dde-f21cdb6ac5a5","topic":"退出区","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"4b8d6309-9350-4fbd-965c-3081a88cb6c3","topic":"解锁","expanded":true}]},{"id":"244961d6-a756-4b7a-a353-b56c34d5a564","topic":"剩余区","expanded":true}]},{"id":"9670afad-87c4-40b1-9847-c0e9a161d8d6","topic":"例如：","expanded":true,"children":[{"id":"695bc30b-3dcb-42af-ba85-f5f02633968c","topic":"公用队列","expanded":true}]},{"id":"bb570680-44da-4410-a1ce-684de2971d15","topic":"反例：","expanded":true,"children":[{"id":"2a4f98c8-719c-4897-8d1a-ec823ca64d83","topic":"磁盘、内存、私有数据、可重入程序代码","expanded":true}]}]},{"id":"cc3d61ea-ce78-459e-9ee8-2dc1c6c5c2a3","topic":"同步：","expanded":true,"children":[{"id":"84210419-9f2d-4818-918d-63d4b628bcc8","topic":"破坏异步性，进程间的制约关系，用来协调进程的工作次序","expanded":true}]},{"id":"f0281227-ea73-4712-9e99-20f835e8f46c","topic":"互斥：","expanded":true,"children":[{"id":"31e594ab-b2cf-4528-88ae-998ba27acb7a","topic":"四大原则","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"2f0c77fc-5a72-45e2-81e2-498ae1a0a61d","topic":"空闲让进","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"ce5825df-9224-4ef3-8ef3-46b19aee2f49","topic":"临界区空闲时，可以允许一个请求进入临界区使用临界资源","expanded":true}]},{"id":"3dd79d74-3e4b-403f-a88a-b882679bc8cd","topic":"忙则等待","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"b26762f4-789a-4ff3-b94b-ec49f87eb48d","topic":"有进程在临界区其他进程必须等待","expanded":true}]},{"id":"0ddebd87-0805-4da9-80d7-cc14c7ab3da9","topic":"有限等待","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"17e4bc93-9fad-488c-8a5d-1deee94fd60b","topic":"保证有限时间内可以进入临界区","expanded":true}]},{"id":"9a634f76-ec4e-4fc0-8593-5e3b83165a82","topic":"让权等待","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"638ecccb-1f43-43f1-b679-ca6e7c437010","topic":"当进程不能进入临界区时，应该释放处理机，防止忙等","expanded":true,"style":{"background":"#0CE6CF"},"children":[{"id":"017827cb-9656-458a-9a1a-527f6c09b40e","topic":"不是按次序进入哦","expanded":true}]}]}]}]}]},{"id":"297d6303-702b-4071-aa0b-dcbaf2d161d5","topic":"临界区互斥：","expanded":true,"children":[{"id":"49dd36f0-d8a0-4d16-b855-45eed57186c7","topic":"软件实现","expanded":true,"children":[{"id":"0a304bc9-6cff-47af-a5ef-74d579f3fef2","topic":"单标志法：","expanded":true,"style":{"background":"#ADADAD"},"children":[{"id":"677143e2-2fef-44a4-b888-9f0e1afd452b","topic":"共享一个整形变量turn，turn = 0 则A进程使用，turn = 1 则B进程使用","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"2c2e6483-5d3a-45c7-9d71-36b0b20e3df5","topic":"等turn = 0后，A进行运行，运行后turn = 1，但是B不运行，则A无法进行下次的运行","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"8e3a10bc-3f71-4fb6-aae2-5cc3b7340a4b","topic":"违背空闲让进，如果一个不运行，另一个永远无法运行","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"39c9f704-8d4c-42e2-95e6-524d8cf24b8c","topic":"双标志先检查：","expanded":true,"style":{"background":"#ADADAD"},"children":[{"id":"4ba78919-d43f-46fa-8ab6-9dc807f106a5","topic":"设置一个flag[]来进行标明哪个进程正在临界区中","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"3927e9b0-23bd-4fc9-9bb5-2d921443df31","topic":"Pi: \nwhile(flag[j]); \nflag[i] = TRUE; \ndo ... ; \nflag[i] = FALSE;\nremainder section;","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"cf4e74ad-144b-4488-a341-cc23545fd4c1","topic":"Pj:\nwhile(flag[i]); \nflag[j] = TRUE; \ndo ... ; \nflag[j] = FALSE;\nremainder section;","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"54386cf7-f824-4395-b398-1af790e08181","topic":"AB可能同时进入临界区（A设置了flag[j]后B立马就进入）","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"5666f679-2ee9-44f3-9c31-e510464b216e","topic":"违背忙则等待，可能同时进入临界区","expanded":true,"style":{"background":"#FF9595"}},{"id":"4c784667-f377-46be-b08b-4c7602573e5f","topic":"使用原语来完成检查+处理","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"b759c2f5-bb03-4c4e-8d6c-7b8559362d0b","topic":"双标志后检查：","expanded":true,"style":{"background":"#ADADAD"},"children":[{"id":"ef6dd614-602c-4b63-8479-5aa08f12abbf","topic":"相比较双标志先检测，把设置flag[]改到前面","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"5128aa7f-14e8-4430-a7d0-bd681f4a2873","topic":"Pi: \nflag[i] = TRUE;\nwhile(flag[j]); \ndo ... ; \nflag[i] = FALSE","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"579e59b1-0c38-48dc-9b3f-9a64c76ef2d4","topic":"Pj: \nflag[j] = TRUE;\nwhile(flag[i]);  \ndo ... ; \nflag[j] = FALSE","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"615bcd20-b27c-4e37-a4d2-cf208ddb8867","topic":"AB若同时设置flag，则谁也进不了do","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"4eb1e2fd-9bf9-4163-8f0f-ba933f38def0","topic":"会引发饥饿，两个进程同时设置了flag，导致双方都无法进入","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"179a4965-e4bd-4275-aa3f-75e1df1eccac","topic":"Peterson算法：","expanded":true,"icons":["star:#ef4444"],"style":{"background":"#FF9595"},"children":[{"id":"f8f95271-ecba-40e4-a024-e88ec7311dc8","topic":"一个flag，一个turn","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"c3f094bb-c143-4cd6-84ad-b25e8a474039","topic":"Pi: \nflag[i] = TRUE; turn = j;\nwhile(flag[j] && turn == j);  \ndo ... ; \nflag[i] = FALSE","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"92ee3232-24f9-406e-b2ef-ad87a33afe2f","topic":"Pj: \nflag[j] = TRUE; turn = i;\nwhile(flag[i] && turn == i); \ndo ... ; \nflag[j] = FALSE","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"9e51ab5c-8283-4b24-8cca-5ac41bb1e7af","topic":"主动争取 + 主动谦让 + 检测","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"4385827c-a1a0-4080-9543-89690a3d66a5","topic":"无法解决让权等待(不停的while，累死cpu)","expanded":true,"style":{"background":"#FDD834"}}]}]}]},{"id":"35a92f61-6dee-4322-b20c-f2f201a55887","topic":"硬件实现","expanded":true,"children":[{"id":"db4ae60d-df27-454d-a667-81b8459bae1d","topic":"中断屏蔽方法：","expanded":true,"children":[{"id":"2387ce2b-3b29-4d28-961c-1cbd47d0e8b0","topic":"使用关中断+临界区+开中断","expanded":true},{"id":"f82c821d-8379-4c3c-a5f8-92fff272dfd7","topic":"优缺点：","expanded":true,"children":[{"id":"e229a22d-479e-4bbd-ba4d-c7b3532e7c84","topic":"优点","expanded":true,"children":[{"id":"09724ba6-b58b-4c02-9162-b9a0b3e7455b","topic":"简单高效","expanded":true}]},{"id":"27a0f7ff-06cf-4367-80e6-9e0f81ca136d","topic":"缺点","expanded":true,"children":[{"id":"56b5509d-5141-479e-93dc-ce8a4bd58958","topic":"只适用单系统，只能用于内核程序","expanded":true}]}]}]},{"id":"7e06a5e0-db80-4715-8245-bfa244265af8","topic":"硬件指令方法：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"fe4e454b-0a97-4ff2-b757-9c70f4fe0dd6","topic":"TestAndSet：先检测后上锁（原语）","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"b5ec0ae8-c683-4477-abb6-4bb178ef0cb2","topic":"原语中查看之前的lock，并修改为自己的","expanded":true},{"id":"07a94906-fb89-48e8-8efe-4d059326c8ef","topic":"bool TestAndSet(bool *lock){\n     bool old;\n     old = *lock;\n     *lock = true;\n     return old;\n}","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"52694451-3385-4c52-97fd-edb2d33928de","topic":"while(TestAndSet(&lock));\n执行;\nlock = false;\n其他代码;","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"383391a3-c8d1-420e-906a-00fc93e6a302","topic":"将双标志后检查法，进行原语实现","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"c088863e-6401-4b3f-8a7a-53adc7516767","topic":"无法解决让权等待","expanded":true,"style":{"background":"#FDD834"}}]}]},{"id":"38507eee-2d3d-46b8-bdd9-27c10380e616","topic":"Swap：交换两个字内容（原语）","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"877dfe0d-6c20-47f6-8c2e-a09f9d37b454","topic":"lock是全局的false，key是局部的true。在原语中，交换lock和key。","expanded":true},{"id":"8010658d-c3d4-4c08-b9f7-08c3e041a50a","topic":"Swap(bool *a, bool *b){\n// 交换AB\n}","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"252e87e3-d909-4bb3-b3dc-ad04d0073d70","topic":"key = true;\nwhile(key != false) \n    Swap(&lock, &key);\ndo....\nlock = false;\n...","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"322081ea-0e35-404a-97df-36c35e9f06e2","topic":"原理和TestAndSet一个样子","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"706f2b60-d89f-43f1-851e-e7dfbff9d211","topic":"无法解决让权等待","expanded":true,"style":{"background":"#FDD834"}}]}]},{"id":"1905acf2-2419-4d74-a467-e50642c6ccb3","topic":"优缺点：","expanded":true,"children":[{"id":"242fea6a-39da-4c7d-96f1-fe020ffebb61","topic":"优点","expanded":true,"children":[{"id":"0af8173c-8f1d-46bd-a8e8-ab2427fc020d","topic":"简单容易、支持进程内有多个临界区，只需要给每一个临界区设置一个bool就可以","expanded":true}]},{"id":"f092ece5-557d-46dd-b7a0-55573ce7d24e","topic":"缺点","expanded":true,"children":[{"id":"a84682e7-581e-41b8-8e71-860752da0fd2","topic":"进程等待的时候饥饿，无法解决让权等待","expanded":true}]}]},{"id":"1423bb34-49db-4649-8cdf-3510d868fb7c","topic":"信号量机制","expanded":true}]}]}]},{"id":"56192984-a8e5-401e-9452-98147b13b1c0","topic":"互斥锁：","expanded":true,"children":[{"id":"dc990e8a-6360-4086-8e9a-d839d2807e3e","topic":"这个的缺点就是【忙等】，会一直占用处理机进行循环","expanded":true,"children":[{"id":"b95f7393-aceb-4342-a0c2-78fff1353550","topic":"acquire()和release()都是原子操作","expanded":true},{"id":"82e6d618-52d4-4722-9ea8-74c50dffb798","topic":"单处理器：","expanded":true,"children":[{"id":"a76e7c82-3dc3-452d-9e3a-ab7f4d34283c","topic":"很蠢的方法，会一直占用CPU又无法解决","expanded":true}]},{"id":"a3445540-d584-42b9-90f5-2879e6cd0446","topic":"多处理器：","expanded":true,"children":[{"id":"7fb686e8-d30b-483c-8355-45d2db8e049f","topic":"不错的方法，因为可能在自己这个时间片另一个CPU上的进程把锁release了","expanded":true,"style":{"background":"#8EDE99"}}]}],"code":{"lang":"c","code":"acquire() {\n    while(!available)\n        ;              // 忙等\n    available = false; // 获得锁\n}\n\nrelease() {\n    available = true;  // 释放锁\n}","tokens":[[{"text":"acquire","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"!","darkColor":"#8EA4E2"},{"text":"available","darkColor":"#DEDBD2"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"              // 忙等","darkColor":"#908B7E"}],[{"text":"    available ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"false","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 获得锁","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":" "}],[{"text":"release","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    available ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"true","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"  // 释放锁","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]}]},{"id":"a17c876e-3823-457f-83f8-27a07965a1be","topic":"信号量：","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-b46a6fdcc50657.svg"},"children":[{"id":"77243343-593c-4e67-af5f-083227ffac73","topic":"信号量可以用于解决互斥和同步问题，只能被Wait和Signal访问","expanded":true,"children":[{"id":"abe16621-c84e-4217-b78f-1a36bcd62f21","topic":"Wait --- P，Signal --- V","expanded":true,"style":{"background":"#8EDE99"}},{"id":"095d0cdc-4836-4b64-9356-8d5fb8c45c73","topic":"Wait：等待S大于零的时候执行；可执行时S--","expanded":true,"children":[{"id":"6f106e52-ea71-4dfc-9402-adeb2c9508b5","topic":"Signal：S++","expanded":true}]},{"id":"37a709ba-d50f-485c-a437-dc1c0191bc42","topic":"PV操作是一种【低级进程通信原语】","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"6cca0063-18dc-4314-b3a0-e8f2e48f6407","topic":"而不是系统调用命令","expanded":true,"style":{"background":"#FDD834"}}]}]},{"id":"c56897fb-a8ce-45a4-a102-0ea8ce45b4c6","topic":"整形信号量：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"8fe09b74-4ee5-4f51-97fa-2ac68078484c","topic":"wait(S) 和 signal(S)，\n其中S是一个int数。","expanded":true,"children":[{"id":"8cb17220-4e46-4487-9504-a2e2ff984334","topic":"wait：S -= 1","expanded":true},{"id":"5ffd5355-aa38-48bd-829d-4d59cffd6474","topic":"signal：S += 1","expanded":true}]},{"id":"5f5bd64f-90ba-47bd-be0f-018371dc5274","topic":"优点：","expanded":true,"children":[{"id":"cd84b64f-b77a-4e48-8938-52a3b047f863","topic":"解决了同步互斥","expanded":true}]},{"id":"407c5648-bed0-4951-a6bb-888145486b57","topic":"缺点：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"11fe6809-3e6d-444a-b1e6-6c338c017feb","topic":"不满足让权等待","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"5effe7ee-ece4-44f6-a83d-537e78f39865","topic":"记录性信号量：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"5eeeb16f-074d-421a-8c74-4fb0f871c7e8","topic":"int + 链表","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"3fa4d9d8-0fef-4a26-a7d3-4e0c79f07e98","topic":"wait: S -= 1; 把进程加入等待队列; 阻塞进程","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"501462ec-9152-462d-a127-219606aef5c3","topic":"signal: S += 1; 把进程从等待队列中移出; 唤醒进程","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"827c8a85-c567-428f-882f-cca91954dd9d","topic":"满足了让权等待","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"eb048cf1-77c9-4f1f-bc78-41f9001a0fe2","topic":"Swait和Ssignal","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"7054fb2e-81a4-4366-927e-907bcf4b89c5","topic":"格式为：Swait(Si, ti, di; ...)","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"c65d5016-2df5-46b6-b4a7-034883116f4a","topic":"对于信号量Si， 每次分配di（即Si = Si - di），如果Si < ti了就不予以分配","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"025d18c2-1987-426b-ac2f-5243dda2d3fd","topic":"信号量实现同步：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"7e32ecdb-e4d3-4fae-85fe-2a77c4de9e4a","topic":"s = 0","expanded":true,"children":[{"id":"93e24542-bdd2-4b26-a805-8863674e6ce1","topic":"A:\ndo x ....\nV(s)","expanded":true,"children":[{"id":"6940313c-2f53-48e1-b1c2-5c8536a32848","topic":"B:\nP(s)\ndo x ....","expanded":true}]}]},{"id":"12845f36-6bbf-4ab7-833e-fef06986a299","topic":"两个进程，先V后P，实现同步","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"1041f927-a54b-4e83-a96e-f3134d9b14e5","topic":"信号量实现互斥：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"a19399a0-4c60-4e56-95fb-9edcac44ee4a","topic":"s = 1","expanded":true,"children":[{"id":"aca0a417-f491-415c-afaa-e04d81113d77","topic":"A:\nP(s)\ndo xxx ...\nV(s)","expanded":true,"children":[{"id":"02a15a50-262b-4d04-ac01-e621a5074586","topic":"B:\nP(s)\ndo xxx ...\nV(s)","expanded":true}]}]},{"id":"18c20b5a-1340-4780-807f-5be918a9a47f","topic":"进程用PV上锁，实现互斥","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"b00ea399-dc26-4c24-aafd-bf2c2864e1e1","topic":"信号量实现前驱关系：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b108c150-5736-4f76-ae0f-6a1aea648180","topic":"A:\nP(s1)\ndo xxx ...\nV(s2)\nV(s3)","expanded":true,"children":[{"id":"7991d10a-33de-4707-98a5-81b6fe255b29","topic":"B:\nP(s2)\ndo xxx ...\nV(s4)\nV(s5)","expanded":true,"children":[{"id":"0f31d41f-b81b-48ed-a5f2-3eeb6cbeb4f6","topic":"...","expanded":true}]}]},{"id":"a5808697-b483-4a66-96d1-94309c4f406e","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1fd5c87c0bfcf5.png","width":285,"height":187}}]}]},{"id":"337eeabd-98f2-4a76-9050-da321b7da0c3","topic":"管程：","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-9f8933b2031653.svg"},"children":[{"id":"a79de90d-db93-4169-93cd-e1bcefd14b3c","topic":"管程最开始是在Pascal语言中引入的","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"98e52e7b-99dd-4bd3-9e50-b39bcbe09d14","topic":"管程就像是一种语法，就像C里面类似static、const等，可以使用也可以不使用，但不可以创建和撤销","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"926fa43b-331d-4f1a-8446-a750b5727ac7","topic":"作用：","expanded":true,"children":[{"id":"6c2a3b97-6179-4926-850c-33ef0a91d1ec","topic":"大量的PV操作给OS的管理带来了麻烦，同步操作不当非常容易死锁。","expanded":true},{"id":"fb148716-e56b-4eec-a96b-c897269908cf","topic":"管程的特性保证了进程互斥，而无须程序员自己实现互斥，从而降低了死锁的可能性","expanded":true,"style":{"background":"#8EDE99"}},{"id":"f1ed7f36-2718-4c39-9426-62bac2ccf30a","topic":"通过入口才能访问数据","expanded":true,"style":{"background":"#FF9595"}},{"id":"70038d88-d8d3-42d1-bb4e-21bf5b1e7d13","topic":"每次仅允许一个进程在管程内执行","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"fa5c0bc8-0700-4237-b315-ad74e2ba996c","topic":"定义：","expanded":true,"children":[{"id":"af822553-9f11-4450-95c0-f019ae070b6b","topic":"1. 管程名称","expanded":true},{"id":"92a7cbdf-6de7-404d-a8f2-5b2b88806b21","topic":"2. 共享数据结构","expanded":true},{"id":"61a97e7e-ac73-48b6-ba44-229934df3c90","topic":"3. 对该数据结构进行操作的一组过程","expanded":true},{"id":"8968ba61-5125-454a-95bc-41e6199d11ae","topic":"4. 对局部于管程内部的共享数据设置初始值","expanded":true}]},{"id":"d5458866-effb-4fd5-adcb-dbbc16b45e70","topic":"类似class数据结构，管程的变量全是private类型","expanded":true},{"id":"908fe2b5-97bf-4bcc-bc2b-231826f097f3","topic":"设置条件变量：","expanded":true,"children":[{"id":"9972e477-89e7-4bce-9b2d-d8c25a6e24d2","topic":"管程条件变量示例","expanded":true,"code":{"lang":"c","code":"monitor Demo {\n    共享数据结构 S;\n    condition x; // 定义一个条件变量 x\n    init_code() { ... }\n    take_away() {\n        // 资源不够，在条件变量 x 上阻塞等待\n        if (S <= 0) x.wait();\n        资源足够，分配资源，做一系列相应处理;\n    }\n    give_back() {\n        归还资源，做一系列相应处理;\n        // 唤醒一个阻塞进程\n        if (有进程在等待) x.signal();\n    }\n}","tokens":[[{"text":"monitor Demo ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    共享数据结构 S","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    condition x","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 定义一个条件变量 x","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"init_code","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" ... ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"take_away","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#BAB5A8"},{"text":"// 资源不够，在条件变量 x 上阻塞等待","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"S ","darkColor":"#DEDBD2"},{"text":"<=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"x","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"wait","darkColor":"#6EC0DF"},{"text":"();","darkColor":"#BAB5A8"}],[{"text":"        资源足够，分配资源，做一系列相应处理","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"give_back","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        归还资源，做一系列相应处理","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#BAB5A8"},{"text":"// 唤醒一个阻塞进程","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"有进程在等待","darkColor":"#DEDBD2"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"x","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"signal","darkColor":"#6EC0DF"},{"text":"();","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}},{"id":"543acf17-b13c-4edf-a840-c49086a1b77b","topic":"使用x来对阻塞队列进行挂载","expanded":true,"children":[{"id":"75073e65-ce62-4169-b088-a7513b6e99b7","topic":"x.wait()","expanded":true,"children":[{"id":"d2456775-e224-4973-be1c-6177bcd1fe96","topic":"当x对应的条件不满足时，正在调用管程的进程调用x.wait将自己插入x条件的等待队列，并释放管程。此时其他进程可以使用该管程。","expanded":true}]},{"id":"2bb0cc26-f549-4033-8435-f6b6c9e57e26","topic":"x.signal()","expanded":true,"children":[{"id":"3f99b3d7-6d99-4317-9a80-23f4a1355e7f","topic":"x对应的条件发生了变化，则调用x.signal,唤醒一个因x条件而阻塞的进程。","expanded":true}]}]},{"id":"ee4a33d6-f349-4ca3-a99e-d99488aecc49","topic":"注意管程的wait、signal和PV操作的区别：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"717cdcc3-d436-4536-95d2-129e80ec1646","topic":"PV操作一定会使信号量++或者--（不论是记录型还是整形）","expanded":true,"style":{"background":"#FDD834"}},{"id":"8c11d262-4222-4585-b553-3de9158efff6","topic":"而管程的signal和wait只负责唤醒、阻塞进程（从阻塞队列中进行唤醒或插入到阻塞队列），不一定会有++--","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"a7bec428-0149-4f2b-8446-cb952fc924c4","topic":"可以有多个condition x","expanded":true,"children":[{"id":"f2a86aa9-4498-4f30-810c-4520687c8620","topic":"可以在一个管程中，管理多个共享资源","expanded":true}]}]},{"id":"b08836f7-736f-4d83-bee6-6b077b39399b","topic":"管程对于生产者\n消费者问题的改进：","expanded":true,"children":[{"id":"aafbff4d-08f8-4b1d-b065-daec48e8a8f0","topic":"管程实现生产者-消费者","expanded":true,"code":{"lang":"c","code":"monitor ProducerConsumer\n    condition full, empty; // 同步条件变量\n    int count = 0;         // 缓冲区中的产品数\n    void insert(Item item) { // 放入缓冲区\n        if (count == N)\n            wait(full);\n        count++;\n        insert_item(item);\n        if (count == 1)\n            signal(empty);\n    }\n    Item remove() { // 从缓冲区中取出一个产品\n        if (count == 0)\n            wait(empty);\n        count--;\n        if (count == N - 1)\n            signal(full);\n        return remove_item();\n    }\nend monitor;\n\n// 生产者进程\nproducer() {\n    while (1) {\n        item = 生产一个产品;\n        ProducerConsumer.insert(item);\n    }\n}\n\n// 消费进程\nconsumer() {\n    while (1) {\n        item = ProducerConsumer.remove();\n        消费产品 item;\n    }\n}","tokens":[[{"text":"monitor ProducerConsumer","darkColor":"#DEDBD2"}],[{"text":"    condition full","darkColor":"#DEDBD2"},{"text":",","darkColor":"#BAB5A8"},{"text":" empty","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 同步条件变量","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" count ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"         // 缓冲区中的产品数","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"insert","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"Item ","darkColor":"#DEDBD2"},{"text":"item","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 放入缓冲区","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"count ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" N","darkColor":"#DEDBD2"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"wait","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"full","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        count","darkColor":"#DEDBD2"},{"text":"++;","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"insert_item","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"item","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"count ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"signal","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"empty","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    Item ","darkColor":"#DEDBD2"},{"text":"remove","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 从缓冲区中取出一个产品","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"count ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"wait","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"empty","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        count","darkColor":"#DEDBD2"},{"text":"--;","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"count ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" N ","darkColor":"#DEDBD2"},{"text":"-","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"signal","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"full","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"remove_item","darkColor":"#6EC0DF"},{"text":"();","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"end monitor","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":" "}],[{"text":"// 生产者进程","darkColor":"#908B7E"}],[{"text":"producer","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        item ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" 生产一个产品","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"ProducerConsumer","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"insert","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"item","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":" "}],[{"text":"// 消费进程","darkColor":"#908B7E"}],[{"text":"consumer","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        item ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"ProducerConsumer","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"remove","darkColor":"#6EC0DF"},{"text":"();","darkColor":"#BAB5A8"}],[{"text":"        消费产品 item","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]}]},{"id":"1102846e-ce1d-47df-b988-04b7968f4d80","topic":"经典同步问题：","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-e8dffdafccd79a.svg"},"children":[{"id":"220de03d-16c2-430b-9336-a33f78cbf7be","topic":"生产者消费者","expanded":true,"children":[{"id":"4c3155ac-7547-4fa5-abd2-0bef629317c0","topic":"问题描述：一组生产者进程和一组消费者进程共享一个初始为空、大小为n的缓冲区，只有 缓冲区没满时，生产者才能把消息放入缓冲区，否则必须等待；只有缓冲区不空时，消费者才能 从中取出消息，否则必须等待。由于缓冲区是临界资源；它只允许一个生产者放入消息，或一个消费者从中取出消息。","expanded":true},{"id":"5b739092-a337-4078-8078-fc98eb928aee","topic":"生产者和消费者是合作协作的关系、同时生产者和消费者对缓冲区是互斥关系","expanded":true},{"id":"3365b194-66b8-4834-afb4-4ec62e3a2a98","topic":"思路：使用两个信号量控制empty和full，一个信号量控制mutex互斥关系即可，缓冲区大小 > 1","expanded":true,"style":{"background":"#8EDE99"}},{"id":"fecb8f96-abc6-4009-ad0f-5db5573ad233","topic":"信号量实现代码","expanded":true,"code":{"lang":"c","code":"semaphore mutex = 1; // 临界区互斥信号量\nsemaphore empty = n; // 空闲缓冲区\nsemaphore full = 0;  // 缓冲区初始化为空\nproducer()           // 生产者进程\n{\n    while (1)\n    {\n        produce an item in nextp; // 生产数据\n        P(empty);            // 获取空缓冲区\n        P(mutex);            // 进入临界区\n        add nextp to buffer; // 放入缓冲区\n        V(mutex);            // 离开临界区\n        V(full);             // 满缓冲区加 1\n    }\n}\n\nconsumer()           // 消费者进程\n{\n    while (1)\n    {\n        P(full);             // 获取满缓冲区\n        P(mutex);            // 进入临界区\n        remove an item from buffer;\n        V(mutex);            // 离开临界区\n        V(empty);            // 空缓冲区加 1\n        consume the item;    // 消费数据\n    }\n}","tokens":[[{"text":"semaphore mutex ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 临界区互斥信号量","darkColor":"#908B7E"}],[{"text":"semaphore empty ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" n","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 空闲缓冲区","darkColor":"#908B7E"}],[{"text":"semaphore full ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"  // 缓冲区初始化为空","darkColor":"#908B7E"}],[{"text":"producer","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":"           // 生产者进程","darkColor":"#908B7E"}],[{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        produce an item in nextp","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 生产数据","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"empty","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"            // 获取空缓冲区","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"            // 进入临界区","darkColor":"#908B7E"}],[{"text":"        add nextp to buffer","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 放入缓冲区","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"            // 离开临界区","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"full","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"             // 满缓冲区加 1","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":" "}],[{"text":"consumer","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":"           // 消费者进程","darkColor":"#908B7E"}],[{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"full","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"             // 获取满缓冲区","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"            // 进入临界区","darkColor":"#908B7E"}],[{"text":"        remove an item from buffer","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"            // 离开临界区","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"empty","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"            // 空缓冲区加 1","darkColor":"#908B7E"}],[{"text":"        consume the item","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"    // 消费数据","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"cc699064-5d2e-4dcb-a5ec-b6c9d756d3f4","topic":"多生产者消费者问题","expanded":true,"children":[{"id":"ece3ff7d-43e7-4215-bb7d-d966cf0d5bb8","topic":"问题描述：桌上有个盘子，每次只能放一个水果。爸爸只放苹果，麻麻只放橘子，儿砸只橘子，女儿只吃苹果。盘子为空才可放，盘子有水果才可拿","expanded":true},{"id":"4c3461e8-802f-4ba8-95c7-84418e422713","topic":"思路：两个生产者两个消费者，所有进程都互斥访问缓冲区，生产者和消费者为合作关系，缓冲区大小为 1","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"607547c2-d3c6-4845-9b93-0cc9419226ab","topic":"使用apple、orange、plate三个信号量即可","expanded":true,"style":{"background":"#8EDE99"}},{"id":"f4ffd5b6-480e-45a6-814c-0912283834ef","topic":"缓冲区大小为 1 可以只用一个信号量， > 1 需要full + empty 两个信号量","expanded":true}]},{"id":"bc474a38-40b6-4eb3-8c78-87ccd9c3e989","topic":"信号量实现代码","expanded":true,"code":{"lang":"c","code":"semaphore plate = 1, apple = 0, orange = 0;\ndad() {                    // 父亲进程\n    while (1) {\n        prepare an apple;\n        P(plate);          // 互斥访问盘子\n        put the apple on the plate;\n        V(apple);          // 允许取苹果\n    }\n}\nmom() {                    // 母亲进程\n    while (1) {\n        prepare an orange;\n        P(plate);          // 互斥访问盘子\n        put the orange on the plate;\n        V(orange);         // 允许取橘子\n    }\n}\nson() {                    // 儿子进程\n    while (1) {\n        P(orange);         // 互斥取橘子\n        take an orange from the plate;\n        V(plate);          // 允许放水果\n        eat the orange;\n    }\n}\ndaughter() {               // 女儿进程\n    while (1) {\n        P(apple);          // 互斥取苹果\n        take an apple from the plate;\n        V(plate);          // 允许放水果\n        eat the apple;\n    }\n}","tokens":[[{"text":"semaphore plate ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" apple ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" orange ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"dad","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"                    // 父亲进程","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        prepare an apple","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"plate","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"          // 互斥访问盘子","darkColor":"#908B7E"}],[{"text":"        put the apple on the plate","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"apple","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"          // 允许取苹果","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":"mom","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"                    // 母亲进程","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        prepare an orange","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"plate","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"          // 互斥访问盘子","darkColor":"#908B7E"}],[{"text":"        put the orange on the plate","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"orange","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"         // 允许取橘子","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":"son","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"                    // 儿子进程","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"orange","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"         // 互斥取橘子","darkColor":"#908B7E"}],[{"text":"        take an orange from the plate","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"plate","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"          // 允许放水果","darkColor":"#908B7E"}],[{"text":"        eat the orange","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":"daughter","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"               // 女儿进程","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"apple","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"          // 互斥取苹果","darkColor":"#908B7E"}],[{"text":"        take an apple from the plate","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"plate","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"          // 允许放水果","darkColor":"#908B7E"}],[{"text":"        eat the apple","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}},{"id":"4c32273f-43e6-4f77-beed-94a433d777fc","topic":"使用管程实现","expanded":true}]},{"id":"86ed56b2-23a9-41ad-b067-e961793c0c07","topic":"读写者问题","expanded":true,"children":[{"id":"33d22160-f60c-4e0d-a158-f2fc5f55d396","topic":"问题描述：有读者写者两个进程，共享文件。多个读者可以同时读文件。只能又一个写者写文件。存在有读者读文件时，不允许写者写。必须写者写完后才可以读。","expanded":true},{"id":"41853691-068c-4c7e-96b2-9679d16db413","topic":"思路：写者比较简单，写者两两互斥，待读者全退出后写。读者两两不互斥，待写者写毕后进行读取","expanded":true,"children":[{"id":"58ead4eb-d048-4df7-920b-7938d6bd7f20","topic":"1. 使用 int 计数器来记录当前读者情况","expanded":true,"style":{"background":"#FF9595"}},{"id":"c5c9ef0c-10a0-424c-8a3e-35e22ea72a35","topic":"2. 使用 信号量 来互斥访问计数器","expanded":true},{"id":"a7a04868-f64f-45be-a7cb-3acdb0cd518a","topic":"3. 使用 信号量 来控制写者能否写入","expanded":true}]},{"id":"d7dab87e-0c02-4a90-b2f9-0ec54b4c9753","topic":"读优先实现代码","expanded":true,"code":{"lang":"c","code":"int count = 0;        // 当前读者数量\nsemaphore mutex = 1;  // 保护 count 互斥\nsemaphore rw = 1;     // 读写互斥访问文件\nwriter() {            // 写者进程\n    while (1) {\n        P(rw);        // 互斥访问共享文件\n        writing;      // 写入\n        V(rw);        // 释放共享文件\n    }\n}\nreader() {            // 读者进程\n    while (1) {\n        P(mutex);     // 互斥访问 count\n        if (count == 0)\n            P(rw);    // 首读阻止写进程\n        count++;      // 读者计数器加 1\n        V(mutex);     // 释放 count\n        reading;      // 读取\n        P(mutex);     // 互斥访问 count\n        count--;      // 读者计数器减 1\n        if (count == 0)\n            V(rw);    // 末读允许写进程\n        V(mutex);     // 释放 count\n    }\n}","tokens":[[{"text":"int","darkColor":"#74CBC4"},{"text":" count ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"        // 当前读者数量","darkColor":"#908B7E"}],[{"text":"semaphore mutex ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"  // 保护 count 互斥","darkColor":"#908B7E"}],[{"text":"semaphore rw ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"     // 读写互斥访问文件","darkColor":"#908B7E"}],[{"text":"writer","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"            // 写者进程","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"rw","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"        // 互斥访问共享文件","darkColor":"#908B7E"}],[{"text":"        writing","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"      // 写入","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"rw","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"        // 释放共享文件","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":"reader","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"            // 读者进程","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"     // 互斥访问 count","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"count ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"rw","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"    // 首读阻止写进程","darkColor":"#908B7E"}],[{"text":"        count","darkColor":"#DEDBD2"},{"text":"++;","darkColor":"#BAB5A8"},{"text":"      // 读者计数器加 1","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"     // 释放 count","darkColor":"#908B7E"}],[{"text":"        reading","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"      // 读取","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"     // 互斥访问 count","darkColor":"#908B7E"}],[{"text":"        count","darkColor":"#DEDBD2"},{"text":"--;","darkColor":"#BAB5A8"},{"text":"      // 读者计数器减 1","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"count ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"rw","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"    // 末读允许写进程","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"     // 释放 count","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}},{"id":"0dbd0d4f-6f20-415b-b163-37958501ba8e","topic":"问题：可能会出现写者饿死的情况","expanded":true,"children":[{"id":"d54f77e5-d315-45f9-9147-87def55dbb0c","topic":"不停的有读者到来","expanded":true}]},{"id":"2f893505-1497-47b8-8bf0-b9bafce1802a","topic":"解决办法：写者申请写入后，读者便不可申请读","expanded":true,"children":[{"id":"9316b84f-10f6-4c62-ba4b-3b59d44acb50","topic":"读写公平（防止写饥饿）实现代码","expanded":true,"code":{"lang":"c","code":"int count = 0;        // 当前读者数量\nsemaphore mutex = 1;  // 保护 count 互斥\nsemaphore rw = 1;     // 读写互斥访问文件\nsemaphore w = 1;      // 用于实现写优先\nwriter() {            // 写者进程\n    while (1) {\n        P(w);\n        P(rw);        // 互斥访问共享文件\n        writing;      // 写入\n        V(rw);        // 释放共享文件\n        V(w);\n    }\n}\n\nreader() {            // 读者进程\n    while (1) {\n        P(w);\n        P(mutex);     // 互斥访问 count\n        if (count == 0)\n            P(rw);    // 首读阻止写进程\n        count++;      // 读者计数器加 1\n        V(mutex);     // 释放 count\n        V(w);\n        reading;      // 读取\n        P(mutex);     // 互斥访问 count\n        count--;      // 读者计数器减 1\n        if (count == 0)\n            V(rw);    // 末读允许写进程\n        V(mutex);     // 释放 count\n    }\n}","tokens":[[{"text":"int","darkColor":"#74CBC4"},{"text":" count ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"        // 当前读者数量","darkColor":"#908B7E"}],[{"text":"semaphore mutex ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"  // 保护 count 互斥","darkColor":"#908B7E"}],[{"text":"semaphore rw ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"     // 读写互斥访问文件","darkColor":"#908B7E"}],[{"text":"semaphore w ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"      // 用于实现写优先","darkColor":"#908B7E"}],[{"text":"writer","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"            // 写者进程","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"rw","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"        // 互斥访问共享文件","darkColor":"#908B7E"}],[{"text":"        writing","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"      // 写入","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"rw","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"        // 释放共享文件","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":" "}],[{"text":"reader","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"            // 读者进程","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"     // 互斥访问 count","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"count ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"rw","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"    // 首读阻止写进程","darkColor":"#908B7E"}],[{"text":"        count","darkColor":"#DEDBD2"},{"text":"++;","darkColor":"#BAB5A8"},{"text":"      // 读者计数器加 1","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"     // 释放 count","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        reading","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"      // 读取","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"     // 互斥访问 count","darkColor":"#908B7E"}],[{"text":"        count","darkColor":"#DEDBD2"},{"text":"--;","darkColor":"#BAB5A8"},{"text":"      // 读者计数器减 1","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"count ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"rw","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"    // 末读允许写进程","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"     // 释放 count","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]}]},{"id":"0f247fb2-13a2-48d2-9a98-d40b0aba924f","topic":"哲学家进餐","expanded":true,"children":[{"id":"83586b0a-45e7-4fc6-a609-29dcb67ba90c","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-e89c880f2112bb.png","width":667,"height":198}},{"id":"754c3aaf-e6ce-4888-9307-ea2764a2acea","topic":"思路：","expanded":true,"children":[{"id":"205d7756-5dc7-4cd2-9899-192bbfb3fe84","topic":"哲学家（较多的进程）和筷子（较少的资源），且进程需要持有两个资源","expanded":true,"children":[{"id":"7a662667-6ad3-4277-b453-31bcd6c57a8c","topic":"设计算法来保证不会发生死锁","expanded":true}]}]},{"id":"c766ac00-7c31-4928-837a-a56f2956c274","topic":"有纰漏的做法：","expanded":true,"style":{"background":"#D0D0D0"},"children":[{"id":"386b3ea5-d9e6-4a58-a119-2233e1caf51a","topic":"这里存在死锁情况，需要➕两点","expanded":true,"style":{"background":"#FF9595"}},{"id":"493ca627-7596-4661-9975-5b02d47685aa","topic":"1. 要么最多只有4个可以同时进餐","expanded":true,"style":{"background":"#8EDE99"}},{"id":"75610870-f4ae-43dd-8004-a69dd8cbcaef","topic":"2. 只有两边筷子都有才可进餐","expanded":true,"style":{"background":"#8EDE99"}}],"code":{"lang":"c","code":"Semaphore chopstick[5] = {1, 1, 1, 1, 1};\nPi() {                     // i 号哲学家进程\n    do {\n        P(chopstick[i]);   // 取左边筷子\n        P(chopstick[(i + 1) % 5]); // 取右筷子\n        Eat;               // 进餐\n        V(chopstick[i]);   // 放回左边筷子\n        V(chopstick[(i + 1) % 5]); // 放右筷子\n        Think;             // 思考\n    } while (1);\n}","tokens":[[{"text":"Semaphore ","darkColor":"#DEDBD2"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"5","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":"};","darkColor":"#BAB5A8"}],[{"text":"Pi","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"                     // i 号哲学家进程","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"do","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#6EC0DF"},{"text":"]);","darkColor":"#BAB5A8"},{"text":"   // 取左边筷子","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[(","darkColor":"#BAB5A8"},{"text":"i ","darkColor":"#6EC0DF"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"%","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"5","darkColor":"#E2B159"},{"text":"]);","darkColor":"#BAB5A8"},{"text":" // 取右筷子","darkColor":"#908B7E"}],[{"text":"        Eat","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"               // 进餐","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#6EC0DF"},{"text":"]);","darkColor":"#BAB5A8"},{"text":"   // 放回左边筷子","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[(","darkColor":"#BAB5A8"},{"text":"i ","darkColor":"#6EC0DF"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"%","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"5","darkColor":"#E2B159"},{"text":"]);","darkColor":"#BAB5A8"},{"text":" // 放右筷子","darkColor":"#908B7E"}],[{"text":"        Think","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"             // 思考","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}},{"id":"d5eb41b8-ee2c-471c-aa91-b023692d4b1c","topic":"正确做法 1 ：只有两边筷子都有才可进餐（每次只有一个哲学家可以拿筷子）","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"a510f321-92d2-4218-84fb-5c30f12bf37e","topic":"正确做法 2：最多允许4名哲学家拿筷子","expanded":true,"style":{"background":"#8EDE99"},"code":{"lang":"c","code":"semaphore chopstick[5] = {1, 1, 1, 1, 1};\nsemaphore count = 4;\nPi() {\n    do {\n        P(count);\n        P(chopstick[i]);\n        P(chopstick[(i + 1) % 5]);\n        ...... // 吃饭\n        V(chopstick[i]);\n        V(chopstick[(i + 1) % 5]);\n        V(count);\n        ...... // 思考\n    } while (1);\n}","tokens":[[{"text":"semaphore ","darkColor":"#DEDBD2"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"5","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":"};","darkColor":"#BAB5A8"}],[{"text":"semaphore count ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"4","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"Pi","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"do","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"count","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#6EC0DF"},{"text":"]);","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[(","darkColor":"#BAB5A8"},{"text":"i ","darkColor":"#6EC0DF"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"%","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"5","darkColor":"#E2B159"},{"text":"]);","darkColor":"#BAB5A8"}],[{"text":"        ......","darkColor":"#DEDBD2"},{"text":" // 吃饭","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#6EC0DF"},{"text":"]);","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[(","darkColor":"#BAB5A8"},{"text":"i ","darkColor":"#6EC0DF"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"%","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"5","darkColor":"#E2B159"},{"text":"]);","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"count","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        ......","darkColor":"#DEDBD2"},{"text":" // 思考","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}],"code":{"lang":"c","code":"Semaphore chopstick[5] = {1, 1, 1, 1, 1};\nSemaphore mutex = 1;       // 取筷子互斥量\nPi() {                     // i 号哲学家进程\n    do {\n        P(mutex);          // 取筷前获互斥量\n        P(chopstick[i]);   // 取左边筷子\n        P(chopstick[(i + 1) % 5]); // 取右筷子\n        V(mutex);          // 释放取筷互斥量\n        Eat;               // 进餐\n        V(chopstick[i]);   // 放回左边筷子\n        V(chopstick[(i + 1) % 5]); // 放右筷子\n        Think;             // 思考\n    } while (1);\n}","tokens":[[{"text":"Semaphore ","darkColor":"#DEDBD2"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"5","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":"};","darkColor":"#BAB5A8"}],[{"text":"Semaphore mutex ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"       // 取筷子互斥量","darkColor":"#908B7E"}],[{"text":"Pi","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"                     // i 号哲学家进程","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"do","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"          // 取筷前获互斥量","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#6EC0DF"},{"text":"]);","darkColor":"#BAB5A8"},{"text":"   // 取左边筷子","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[(","darkColor":"#BAB5A8"},{"text":"i ","darkColor":"#6EC0DF"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"%","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"5","darkColor":"#E2B159"},{"text":"]);","darkColor":"#BAB5A8"},{"text":" // 取右筷子","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"mutex","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":"          // 释放取筷互斥量","darkColor":"#908B7E"}],[{"text":"        Eat","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"               // 进餐","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#6EC0DF"},{"text":"]);","darkColor":"#BAB5A8"},{"text":"   // 放回左边筷子","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"chopstick","darkColor":"#EEECE6"},{"text":"[(","darkColor":"#BAB5A8"},{"text":"i ","darkColor":"#6EC0DF"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"%","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#6EC0DF"},{"text":"5","darkColor":"#E2B159"},{"text":"]);","darkColor":"#BAB5A8"},{"text":" // 放右筷子","darkColor":"#908B7E"}],[{"text":"        Think","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"             // 思考","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}},{"id":"ab2d5501-07bb-42cc-a5ff-d34f2498f763","topic":"哲学家算法是贪心算法的反面","expanded":true}]},{"id":"8931084c-9adb-41d3-8bac-899edb0a5814","topic":"吸烟者","expanded":true,"children":[{"id":"9cea475a-680b-4f25-ac0b-f23461434f9b","topic":"问题描述：假设一个系统有三个抽烟者进程和一个供应者进程。每个抽烟者不停地卷烟并抽掉它，但要卷起并抽掉一支烟，抽烟者需要有三种材料：烟草、纸和胶水。三个抽烟者中，第一个拥有烟草，第二个拥有纸，第三个拥有胶水。供应者进程无限地提供三种材料，供应者每次将两种材料放到桌子上，拥有剩下那种材料的抽烟者卷一根烟并抽掉它，并给供应者一个信号告诉已完成，此时供应者就会将另外两种材料放到桌上，如此重复(让三个抽烟者轮流地抽烟)。","expanded":true},{"id":"ab9c4793-4b24-4ee6-b278-34727832849b","topic":"分析：","expanded":true,"children":[{"id":"a5fb21ee-a704-4b38-ab1c-3e008124cf22","topic":"三种消费者分别只持有A, B, C三种资源，当有任意两种资源可使用时，哪个消费者应该去获得资源","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"6c3c1db9-0ef8-448d-a192-bc100ad32610","topic":"生产者：轮流产生（也可以使用random()来随机)","expanded":true,"children":[{"id":"4ec3e731-4513-4a82-a361-eb2511b5f01f","topic":"消费者：","expanded":true,"code":{"lang":"c","code":"process P2() {         // 拥有烟草者\n    while (1) {\n        P(offer3);\n        拿纸和胶水，卷成烟，抽掉;\n        V(finish);\n    }\n}\nprocess P3() {         // 拥有纸者\n    while (1) {\n        P(offer2);\n        拿烟草和胶水，卷成烟，抽掉;\n        V(finish);\n    }\n}\nprocess P4() {         // 拥有胶水者\n    while (1) {\n        P(offer1);\n        拿烟草和纸，卷成烟，抽掉;\n        V(finish);\n    }\n}","tokens":[[{"text":"process ","darkColor":"#DEDBD2"},{"text":"P2","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"         // 拥有烟草者","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"offer3","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        拿纸和胶水，卷成烟，抽掉","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"finish","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":"process ","darkColor":"#DEDBD2"},{"text":"P3","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"         // 拥有纸者","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"offer2","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        拿烟草和胶水，卷成烟，抽掉","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"finish","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":"process ","darkColor":"#DEDBD2"},{"text":"P4","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"         // 拥有胶水者","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"offer1","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        拿烟草和纸，卷成烟，抽掉","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"finish","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}],"code":{"lang":"c","code":"int num = 0;           // 存储随机数\nsemaphore offer1 = 0;  // 烟草和纸的组合\nsemaphore offer2 = 0;  // 烟草和胶水的组合\nsemaphore offer3 = 0;  // 纸和胶水的组合\nsemaphore finish = 0;  // 抽烟是否完成\nprocess P1() {         // 供应者\n    while (1) {\n        num++;\n        num = num % 3;\n        if (num == 0)\n            V(offer1); // 提供烟草和纸\n        else if (num == 1)\n            V(offer2); // 提供烟草和胶水\n        else\n            V(offer3); // 提供纸和胶水\n        任意两种材料放在桌子上;\n        P(finish);\n    }\n}","tokens":[[{"text":"int","darkColor":"#74CBC4"},{"text":" num ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"           // 存储随机数","darkColor":"#908B7E"}],[{"text":"semaphore offer1 ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"  // 烟草和纸的组合","darkColor":"#908B7E"}],[{"text":"semaphore offer2 ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"  // 烟草和胶水的组合","darkColor":"#908B7E"}],[{"text":"semaphore offer3 ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"  // 纸和胶水的组合","darkColor":"#908B7E"}],[{"text":"semaphore finish ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":"  // 抽烟是否完成","darkColor":"#908B7E"}],[{"text":"process ","darkColor":"#DEDBD2"},{"text":"P1","darkColor":"#6EC0DF"},{"text":"()","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"         // 供应者","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        num","darkColor":"#DEDBD2"},{"text":"++;","darkColor":"#BAB5A8"}],[{"text":"        num ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" num ","darkColor":"#DEDBD2"},{"text":"%","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"3","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"num ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"offer1","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":" // 提供烟草和纸","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"else","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"num ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"offer2","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":" // 提供烟草和胶水","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"else","darkColor":"#8EA4E2"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"V","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"offer3","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"},{"text":" // 提供纸和胶水","darkColor":"#908B7E"}],[{"text":"        任意两种材料放在桌子上","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"P","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"finish","darkColor":"#6EC0DF"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"1c09ba92-b7c9-4f3a-bf15-19cf24a2721f","topic":"大题总结：","expanded":true,"children":[{"id":"07f165cf-7bed-4c40-bb54-56489e0c0117","topic":"【2014年 连续取问题】\n题中有消费者连续取10件后才能让另一个取","expanded":true,"children":[{"id":"037ac119-fa74-4a78-9fe8-1a32b450dc2b","topic":"不能通过while + count 的方法，会死锁。应该直接for(i = 1...10)","expanded":true}]},{"id":"a4529203-7c39-4cb3-ba34-cafd1c8356e9","topic":"【2015年 基本mutex问题】\n题中说有AB两人，都可以操作AB的信箱","expanded":true,"children":[{"id":"f9fb6937-e8fa-4037-8dc1-81826e7c7748","topic":"注意AB的信箱都是临界资源（在考题中出现了现实生活中的内容，记得分辨清楚）","expanded":true}]},{"id":"7752a1ed-b68b-4418-9ed5-fb846ae898d6","topic":"【2017年 3线程复数相加问题】\n在考察死锁的同时，AB线程是读者，C线程是写者。故AB线程和C线程应该有互斥关系，而AB之间无互斥关系","expanded":true,"children":[{"id":"c11bc173-dd1a-4cf5-87d5-17febca5add9","topic":"注意答案不是“公平读写”","expanded":true}]},{"id":"fcf2b6ba-d5a8-40d3-aee8-751b4f51ffe1","topic":"【2019年 哲学家 + 碗问题】\nn个哲学家，m个碗","expanded":true,"children":[{"id":"a16345ed-1a69-49ab-9019-a743da85af2a","topic":"1. 哲学家问题的最优解是同时只让 n-1 个哲学家拿筷子","expanded":true,"children":[{"id":"dfb5ed53-7800-4606-b239-18ebd1c52c2b","topic":"次优解是每次只能一个哲学家拿筷子","expanded":true}]},{"id":"edcc3f5b-af7d-448e-895e-a61803609ffc","topic":"2. 碗可以用来控制哲学家拿筷子的最大并发数。这里的碗如果多了，就只能 n-1 个拿。如果少了，那么就直接用碗就可以了","expanded":true}]}]},{"id":"b6b386ec-15b9-4c90-a6e0-0288d72a90ee","topic":"考频：超高","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"37bf7e07-6efc-4560-9ec0-68805cb90dcc","topic":"10*2、11、16*3、18*3、20、09大、11大、13-15大、17大、19-22大","expanded":true}]}]},{"id":"6e6c297a-03be-4092-bbc4-c13f9752a8e3","topic":"死锁","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-a16e15fc1ea7bb.svg"},"children":[{"id":"2503954e-0faf-4358-860c-7625be56163f","topic":"考频：超高","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"72813df0-d0c6-47bf-bb8b-500577555eed","topic":"09、11-16、18-22","expanded":true}]},{"id":"21b5a5d0-237e-49ed-b534-5d07b43f9a84","topic":"死锁概念：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"739900e7-784b-4ed0-a1fe-7a9fd417c333","topic":"两个或两个以上的进程争夺资源","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"296668c6-d7fa-43d7-81d0-984250ebe3bc","topic":"饥饿只是一个进程得不到资源","expanded":true}]},{"id":"ded8062f-d776-45d2-a219-1f5a65949843","topic":"两大原因：","expanded":true,"children":[{"id":"a1e3c7f9-d12b-4806-afd8-bc8aecdb7b58","topic":"资源分配不合理","expanded":true},{"id":"448df88a-b354-4abe-bd2a-57aa621f388d","topic":"进程推进顺序非法","expanded":true}]}]},{"id":"9adca232-35c6-4148-94d5-1d132d4f9f9b","topic":"产生的必要条件：\n（死锁一定满足这四个，\n这四个不可反推死锁）","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"569186ed-b8f8-45ac-8ae0-885091de7b10","topic":"互斥条件","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"82c5ab0f-90d9-4ede-848f-cc35dd49bb97","topic":"资源不可同时被访问","expanded":true,"children":[{"id":"c67d35e4-8c85-497b-a3ca-f23cb96b131d","topic":"反例：扬声器、内存","expanded":true}]}]},{"id":"e1e92c8b-5cb3-40c1-829e-59124b0c65e7","topic":"不剥夺","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"d0463b2a-a1ae-4cc9-a62e-69d1b24c079d","topic":"未使用完时，不能被抢走","expanded":true}]},{"id":"3db2b6cc-b156-43d7-8324-7a5aa2ceadb8","topic":"请求+保持","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"1d16b5fb-1ea9-477c-9825-fe352fd0b15f","topic":"如果P1持有了A，P1也想要B；此时P1堵塞，也不释放A","expanded":true}]},{"id":"4684bd0e-85a5-4348-94e8-997f4d3e1378","topic":"循环等待","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"3229b6fa-4e81-4533-a8af-bd030bdbd0f1","topic":"在资源分配途中，存在资源循环链","expanded":true}]}]},{"id":"fc58dddb-d5fd-4377-b98a-facf62491ef9","topic":"四种处理策略","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e7780127-c0ea-4b19-8b97-8233b8304f76","topic":"死锁预防","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e6ebb372-0873-447b-a7be-509b2be43e48","topic":"破坏互斥：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"749259cf-213b-4653-ac7b-badc85fe8547","topic":"SPOOLing技术","expanded":true},{"id":"add0c745-781b-475a-9de8-43e69219fcbb","topic":"缺点：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"c95734d9-4c46-4f22-8ee8-e0ea322e9928","topic":"有些资源根本不可以共享","expanded":true}]}]},{"id":"c94e55fb-a909-4272-a1ca-b7347db11bd0","topic":"破坏不剥夺：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"6425a8d7-7337-4e5b-af19-c9a87345109a","topic":"可以进行剥夺","expanded":true,"children":[{"id":"3aba9133-8bdc-4bfc-8c9c-3be0124dce34","topic":"自己堵塞，全部释放","expanded":true},{"id":"785d89a1-0431-4cc0-8221-36cf6f94c4a4","topic":"自己想要，强行抢占","expanded":true}]},{"id":"bfa66b57-69ef-4737-b41c-f904b8fef759","topic":"缺点：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"5ff34bf7-3236-4aaa-b0d0-02dbca166d58","topic":"实现复杂，反复的申请和释放资源会增加系统开销","expanded":true}]},{"id":"017da64d-00c7-4ce3-802b-538980c4c286","topic":"特点：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"82545d9e-9eb1-4c8c-a418-d41edac3cbf1","topic":"这种方法适用于【状态易于保护和恢复的资源】，例如CPU、内存等等","expanded":true}]}]},{"id":"8fe1a493-a539-4bf7-8825-1bb3a15efaca","topic":"破坏请求保持：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"7333adec-85bf-4d23-a74a-397f9501dd6f","topic":"一次申请完。不够就不要，够就直接运行","expanded":true},{"id":"124cf5e9-29ab-4b15-8c42-ce65451513de","topic":"缺点：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"8428dbac-b414-43ca-983c-7014c7d73be0","topic":"系统资源容易被浪费，有些资源可能只有进程最开始用一下，后续也不释放","expanded":true},{"id":"296e0d0b-6149-478a-8fb2-a4bc4897dc4d","topic":"导致饥饿","expanded":true}]}]},{"id":"b4448fbb-5f88-4a21-80dd-711204363744","topic":"破坏循环等待：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"9d1c1067-5bb3-49a4-8b4d-b5cd3cb5c717","topic":"给系统资源编号","expanded":true},{"id":"8ea53220-040f-42c7-9b5d-724569a9881c","topic":"缺点：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"5671a79b-958a-473f-98b0-dadc2b4cb7c5","topic":"编号必须相对稳定","expanded":true},{"id":"11d7c53e-0a14-40ae-b766-af83427afadf","topic":"经常会发生作业使用资源顺序和系统规定顺序不同，造成浪费","expanded":true},{"id":"c806f9da-22a5-4974-8dbf-8985e55273c7","topic":"按规定次序申请，会很难coding","expanded":true}]}]}]},{"id":"d30e6b5e-4e0f-48b7-bb26-3167790488e2","topic":"死锁避免","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"00b94c8b-8253-4963-9cb0-9fd757ac9cbc","topic":"银行家算法","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"5c0e5dbd-0e7b-46c1-a8cc-79352e0618a3","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-7af6e9d377d9df.png","width":327,"height":161}}]}]},{"id":"64234ada-7387-44ff-affc-629166437286","topic":"死锁检测","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"763ae947-42e6-43de-8c54-8b2abc82724d","topic":"资源分配图找安全序列","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f5bacbf302b1a1.png","width":324,"height":204},"children":[{"id":"62a09b17-8b67-4b58-9aee-5ee3ad990f08","topic":"如果图不可简化，则为死锁","expanded":true}]}]},{"id":"f056f7e4-3589-4d51-aa73-6e55a7c31103","topic":"死锁解除","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e38174cd-cb1a-454b-83bc-fbe4d3399878","topic":"资源剥夺法","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"9a00c00d-f4a0-434a-9863-b07dbbfeec25","topic":"挂起某些死锁进程，剥夺资源分配给其他死锁进程。注意防止被挂起进程饥饿","expanded":true}]},{"id":"dfeaa951-bdea-4d91-a219-4e01dca8a0cf","topic":"撤销进程法","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"6e3ac6cb-4f7d-4757-8d2d-766f0db7c8d1","topic":"强制撤销部分/全部死锁进程并剥夺这些进程的资源。代价大，撤销按进程优先级进行","expanded":true}]},{"id":"7f0f8e36-fdf6-4454-8312-6cca0ab88fe0","topic":"进程回退法","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"3585bb7e-4bad-4e36-ad5b-0d88d1eb3ad9","topic":"让一个或多个进程回退到足以避免的时刻。系统需要保持进程的历史情况","expanded":true}]}]},{"id":"78747809-ec64-4cb5-8773-f3df269f27b6","topic":"感觉死锁避免和检测的灵活性不够，银行家算法这种算法完全可以检测到死锁的，资源有向图这种数据结构也是完全可以提供进程使用资源的顺序的","expanded":true,"style":{"background":"#D0D0D0"}}]},{"id":"1e87df6b-73d7-4e9e-89d1-2a7b621ac94b","topic":"死锁与不安全态：","expanded":true,"children":[{"id":"2ea94bb3-f2a2-4520-8fa8-f68993488578","topic":"不安全态 > 死锁，如果系统中现在有些进程持有了很多资源正在运行，而且现在系统中的资源无法进行正常分配（不安全）。但是这些进程运行完毕释放资源后，就可以正常分配资源了（非死锁）","expanded":true}]}]},{"id":"02ad6150-071e-4b01-b6fc-321f6f3c9a3b","topic":"END","expanded":true}]},"relations":[{"id":"80369f26-f94d-45db-8652-ae0feb833782","from":"10a727f9-ffa5-41e4-899d-3822ffa9e532","to":"3d79f212-9dec-43fc-8eb6-71add89ea4eb","bidirectional":false,"style":{"stroke":"#ADADAD"}}],"summaries":[{"id":"fd2c9656-ff98-4622-b1d3-6c5d42aca6e5","parentId":"6cbaef13-ee9a-4d01-aca3-d1b58515ccb1","start":1,"end":2,"label":"故同一程序不同进程：其PCB不同、程序段相同、数据段不同"},{"id":"ebc3fba1-969b-4fcf-a706-8a54dfaef406","parentId":"9d02ab22-325e-4183-bef2-5f51bd471843","start":0,"end":0,"label":"通：硬件"},{"id":"dc5e9257-848e-4519-94bb-4f9225d7c12b","parentId":"9d02ab22-325e-4183-bef2-5f51bd471843","start":1,"end":2,"label":"管：软件"},{"id":"d5c209bf-0a35-408a-bed5-b83c7f0c8188","parentId":"02dd5856-5fa1-4ae2-9fbd-b1c0022df670","start":0,"end":0,"label":"1:1"},{"id":"dad56363-c541-422f-99e8-93b490b55196","parentId":"51e19291-73c8-4f07-86c1-a2d3a2f8b8f0","start":0,"end":0,"label":"N:1"},{"id":"29a54f9f-2237-439c-9bf1-93fb9b71b8d2","parentId":"a199462e-5a4f-49bd-b3fb-0764492fb4ae","start":0,"end":0,"label":"N:M (N>=M)"},{"id":"cbd0a24b-d564-4eb4-b027-5e679acc52fe","parentId":"bb4bfd14-36ae-4da8-b7b7-aa2e5ed8de08","start":0,"end":2,"label":"可以获得较好的I/O设备利用率和缩短响应时间而照顾I/O型进程"},{"id":"d9aeafdc-839e-4c35-9e0f-e854f8cb8180","parentId":"337eeabd-98f2-4a76-9050-da321b7da0c3","start":2,"end":2,"label":"每次只能一个进程访问管程函数"},{"id":"d36e7a67-7c66-4419-8c27-42f19401f3da","parentId":"fc58dddb-d5fd-4377-b98a-facf62491ef9","start":2,"end":3,"label":"系统只是提供检测和解除手段，不会有任何实质上的措施"}],"boundaries":[{"id":"fde50024-8c9a-4cda-8d05-4492d515cd09","parentId":"40bc6e71-6875-4924-b8c9-c4766d956698","start":2,"end":2,"label":"题目中出现，找最对最错，都要考虑"},{"id":"1357f61b-0f44-4dc1-8c7d-66dd4e465caa","parentId":"a17c876e-3823-457f-83f8-27a07965a1be","start":2,"end":2,"label":"题目不说，默认是对记录型信号量处理"},{"id":"ce3bc4f6-ea9d-480a-a6c4-f25d9c542c16","parentId":"86ed56b2-23a9-41ad-b067-e961793c0c07","start":3,"end":4,"label":"读写公平法","style":{"stroke":"#19A719"}},{"id":"8476ae98-44de-4929-b838-97be70372e56","parentId":"1102846e-ce1d-47df-b988-04b7968f4d80","start":5,"end":5,"label":"重要考点"},{"id":"21624b17-058c-47c4-ba12-e01d83b4efae","parentId":"21b5a5d0-237e-49ed-b534-5d07b43f9a84","start":0,"end":1,"label":"都是OS分配资源不合理导致"}]}}},{"id":"7ceca8cb-d818-40e1-baab-58e48646dd4d","topic":"内存管理","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/operating-systems/os-00-sheet3","expanded":false,"maxHeight":260,"doc":{"format":"brushup-mindmap-v1","id":"os-00-sheet3","title":"内存管理","structure":"timeline-h","theme":"auto","root":{"id":"bf58d12bd5489ee4093d39481d","topic":"内存管理","expanded":true,"children":[{"id":"a52a50e9a01ab3260e552a7fd9","topic":"作用：","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c036e009774e06.svg"},"children":[{"id":"51cb7acdc2daa508e5976b987a","topic":"内存空间的分配和回收","expanded":true,"children":[{"id":"99fe203b-97f4-41d2-a027-6be66688b7c7","topic":"OS决定的如何分配回收","expanded":true}]},{"id":"db283d2181fb4081909ccb6b71","topic":"地址转换","expanded":true,"children":[{"id":"7bf53108-30e2-43f3-b116-20ad3ca908ce","topic":"逻辑地址转为物理地址","expanded":true}]},{"id":"0f6b395aa5ea0b005ad96a3523","topic":"内存空间的扩充","expanded":true,"children":[{"id":"6487dd24-b386-47d6-a9a5-f68bbe36c561","topic":"利用例如：覆盖、交换、虚拟存储的技术来实现内存扩充","expanded":true}]},{"id":"9778207ff45a68f9bde328329b","topic":"存储保护","expanded":true,"children":[{"id":"8a805bd3-3ab4-4c6f-891d-65d4b857f1f2","topic":"保证各个作业在不同的存储空间内运行，不受干扰","expanded":true}]},{"id":"08716fc3-3138-42b3-9b91-2bce90c72aab","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a0d26a3a-a12a-402c-9d94-16ffc386d128","topic":"无","expanded":true}]}]},{"id":"771a25eee418e45106c69b31de","topic":"内存管理的基本原理和要求","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1235130106af99.svg"},"children":[{"id":"e8f2c9ab-74c3-4421-b017-8a3746c08620","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"2e896c93-375a-47db-946a-887f51860786","topic":"09","expanded":true}]},{"id":"8265414c-68cb-44b5-9f5b-0c166f90e8d2","topic":"流程：","expanded":true,"children":[{"id":"81feb1bf-587e-4811-942c-83c8dccab397","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-76232d8d951ab7.png","width":505.7,"height":204.96}}]},{"id":"5009aa6651c81e7dfb3e893718","topic":"编译","expanded":true,"children":[{"id":"88db12e49f08f7736bbe68e3e7","topic":"编译的步骤：","expanded":true,"children":[{"id":"98553431-1928-42fb-adcc-10941b17d1ad","topic":"源代码文件 .c","expanded":true,"children":[{"id":"d26dad71-5f74-4d14-9256-08de9e541d7b","topic":"预处理 -> .i","expanded":true,"children":[{"id":"3119a0ac-1c3f-4cd0-b521-e42a64440fff","topic":"编译 -> .s","expanded":true,"children":[{"id":"d5ab1655-083b-447e-8cf9-6655822057bf","topic":"汇编 -> .o","expanded":true,"children":[{"id":"245522b8-ec39-455a-bba2-c90fef9e3a8a","topic":"链接 -> .exe","expanded":true}]}]}]}]}]},{"id":"043f3315-e494-4fc6-98c8-0c2583f066e0","topic":"编译后产生的目标模块地址都是从0开始的相对地址","expanded":true}]},{"id":"acc9eaa596db10ff4af0087358","topic":"链接","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"3052dfd0-2231-4f34-9f3c-283732f551d3","topic":"概念","expanded":true,"children":[{"id":"1a45b441-55f2-4010-8e6e-149e47e7d913","topic":"由链接程序把库函数和目标模块连着一起","expanded":true,"children":[{"id":"d9daaf5f-a45a-421a-a80a-f301a15c85fa","topic":"库代码也需要新分配空间","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"db6b51ccfe0a57415bed5b0f57","topic":"静态链接","expanded":true,"children":[{"id":"bf060766-3497-4126-9516-d0bd16335e58","topic":"程序运行前，把目标模块、库文件链接成同一个完整的装配模块，后不再拆开","expanded":true}]},{"id":"224a389276b8bc9d0668d9423c","topic":"装入时动态链接","expanded":true,"children":[{"id":"f9dc73de-0dea-44c4-8874-e8b20f08349c","topic":"程序在装入内存时，边进行装入边链接","expanded":true},{"id":"42c29b09-b9e7-41a6-a9ff-f394be2e6ce7","topic":"易于修改和更新，便于共享","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"68490b4adb88f487aa646a2620","topic":"运行时动态链接","expanded":true,"children":[{"id":"59dcdbf9-f8e2-424a-b7cd-66df096fc78d","topic":"程序装入时不进行链接，运行时才链接（动态链接库DLL）","expanded":true},{"id":"96bbad3c-7209-4ff2-9332-f854d0386dd3","topic":"在执行过程中未被用到的目标模块，都不会被调入内存和被链接到装入模块上","expanded":true},{"id":"3f509ed2-ccf6-4be3-8c98-882f0aa61a35","topic":"优点是能加快程序的装入过程， 还可节省大量的内存空间。","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"88bbab02278b0a1accecd925e1","topic":"装入","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"fb93db98-c389-441c-b540-8dce9287b8b9","topic":"概念","expanded":true,"children":[{"id":"6aba238b-77db-4bc8-b2ac-76b23ad0ee05","topic":"从逻辑地址更改到物理地址","expanded":true}]},{"id":"13eb999960da13f08e91693e86","topic":"绝对装入","expanded":true,"children":[{"id":"267b78b1-40ee-4002-a0d2-ffb6cc4fc65d","topic":"代码中的逻辑地址与物理地址相同，编译时装入（只适用单道程序）","expanded":true}]},{"id":"31baf3afe8794c8ee93928cac0","topic":"可重定位装入\n（静态重定位）","expanded":true,"children":[{"id":"72feccc3-bae6-44b2-aaaa-bbc079431048","topic":"程序执行之前，完成逻辑地址和物理地址的转换，运行时内存不移动也不再申请空间。","expanded":true}]},{"id":"7118cccc0d293adf5ddf392232","topic":"动态运行时装入\n（动态重定位）","expanded":true,"children":[{"id":"cb5f0ed7-a13b-485b-b71b-47e3478ba8d1","topic":"运行时才进行逻辑地址到物理地址的转化","expanded":true},{"id":"728cf15c-8ef2-48b5-b5bb-56569e0a6ed3","topic":"整个系统中只设计一个重定位寄存器，所有进程共享使用","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"06f3127f-a76f-4f27-bc91-2f1a153e7d85","topic":"逻辑地址与物理地址","expanded":true,"children":[{"id":"324b52d0-de58-4bbb-863b-362f1939d90a","topic":"通过MMU（内存管理部件）将逻辑地址转为物理地址","expanded":true}]},{"id":"3fbb9a89-a095-4ced-9355-a4a5e208ae73","topic":"程序运行的内存映像和地址空间","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"f5ff23f4-34e9-4e5c-a7dd-8509405de8ea","topic":"内存中程序几大部分","expanded":true,"children":[{"id":"13ecb7a4-bae7-4646-8a44-aee4f7cfd7e2","topic":"只读代码段（可被共享）","expanded":true},{"id":"697f67e9-c221-43dd-a3fc-2dc1d5b3c963","topic":"数据段（保存全局和静态变量）","expanded":true},{"id":"29bbca81-5b69-48a7-99d0-610fad48aee4","topic":"PCB进程控制块（放在系统区，由操作系统控制）","expanded":true},{"id":"37d36125-e0ae-4d3b-9ce8-c9a2a797151b","topic":"堆（存放动态分配的变量）","expanded":true},{"id":"476d023a-a710-4039-a918-e9308e866024","topic":"栈（实现函数调用）","expanded":true}]},{"id":"6ef0f447-c1f8-4cd8-8d0e-1ab20ed915ea","topic":"图示","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-0eec13675edffb.png","width":516,"height":419}},{"id":"4ec901b5-c077-400a-8353-5769a04361b3","topic":"MMU（内存管理部件）","expanded":true,"children":[{"id":"d94366e4-af36-4fed-b517-e73cf4d6f56b","topic":"一个把虚拟地址转为物理地址的程序","expanded":true}]},{"id":"e45f3bea-3fb4-4dc5-9bb1-fce1aa94fe29","topic":"在虚拟存储系统中，每个进程都有独立的地址空间，空间中的地址为虚拟地址","expanded":true,"children":[{"id":"c5bc29f6-3de0-4075-870c-bdf81937c485","topic":"可以通过MMU来转为物理地址","expanded":true}]}]},{"id":"ade8d604dc7bfa4bbf52c97ff7","topic":"内存保护","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"30b145a2-9bd9-4587-a159-f8ceb2f15aef","topic":"方法一：上下限寄存器","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"15733745-6000-451d-8d16-3f1609f87b36","topic":"方法二：重定位 + 届地址寄存器","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"31a72de9-aea4-432c-83c3-567a4e97e932","topic":"better","expanded":true}]}]},{"id":"1871d1c0-35ac-4307-a37c-3fd4f56be5c7","topic":"内存共享：","expanded":true,"children":[{"id":"983507cc-6152-4554-bff4-e259d03aa25e","topic":"后面细讲","expanded":true}]},{"id":"1b328bee-29ae-4cca-8ab5-ee6921363497","topic":"内存分配和回收","expanded":true}]},{"id":"31fade1a616a400a7d78285595","topic":"覆盖和交换","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ee2929a9461dbe.svg"},"children":[{"id":"c2a861faa21ba59cc98f9b79cd","topic":"覆盖和交换","expanded":true,"children":[{"id":"09555561-1f7f-4109-91ae-052161552e3a","topic":"覆盖：","expanded":true,"children":[{"id":"bc060dd4-77af-4a0d-b578-88cc6101726b","topic":"把内存分为固定区 + 覆盖区","expanded":true,"children":[{"id":"b480861f-3d6c-427a-b9c3-f3688fe636cc","topic":"经常活跃的部分放在固定区中","expanded":true},{"id":"7dcfb075-2396-4604-ad64-e365e5322152","topic":"即将访问的段放在覆盖区中，其他放在外存","expanded":true}]},{"id":"05a6bc99-07de-4a1c-90c1-06f74e569c5a","topic":"固定区就是不可被覆盖的","expanded":true},{"id":"0571156e-0f3d-4637-8188-aaa0d8dbe86c","topic":"用于单一连续存储管理","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"7fe7ed08-a5a1-4229-ac5a-04dbbf6e1750","topic":"交换：","expanded":true,"children":[{"id":"68d128cb-3906-4f4b-a503-cee940024c82","topic":"换出：把处于等待状态的程序从内存移到辅存，就可以把内存空间腾出来","expanded":true},{"id":"8ad391cd-a10b-43e7-a974-31c194e79624","topic":"换入：把准备好竞争CPU进程从辅存移动到内存","expanded":true,"children":[{"id":"6dda09ed-0d38-4e87-867a-4f83f1490af4","topic":"中级调度","expanded":true}]},{"id":"38cd43ab-6a79-4446-89ed-8d72140ee3d4","topic":"不同状态的进程\n能否交换：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"81e600e4-67fb-438b-b4f9-7265dd998660","topic":"创建态，可以","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"6527aa5f-2ac3-4d18-9f83-3203634964b8","topic":"即创建态 -> 挂起态","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"fad99151-20c8-4e78-a3b5-239ad14dd4c7","topic":"死锁，可以","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"93d594fb-2316-4bca-a610-205c5d5dc822","topic":"非常好","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"8f12ad06-7e89-424b-bcc3-63c65636661f","topic":"处于临界区，不行","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"84ae06e3-f809-4af0-bca5-0b1b2e2fb776","topic":"因为这片临界区的访问会一直阻塞，直到该被挂起的进程重新恢复","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"9e7ee15b-c62f-45bd-814b-b74ce7a74dbd","topic":"正在IO操作，不行","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"b768e6f3-d339-4014-9467-febf63f770d8","topic":"如果是A进程Input阶段，则可能造成新的B进程交换后，输入设备覆盖掉了B进程的指令","expanded":true,"style":{"background":"#FFABD5"}}]}]}]}]},{"id":"b72dc743-6a36-45a9-b079-d53a9d611081","topic":"可重入程序：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"45eb1a69-8eb1-4f2c-9683-d60541099a90","topic":"法一：共享使用同一块存储空间","expanded":true,"style":{"background":"#FFABD5"}},{"id":"3bbfd447-deea-4130-9ebc-4deb31df8904","topic":"法二：通过动态链接的方式将所需的程序段映射到相关的进程中","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"d4f8985f-a107-40c0-ba7a-57dcb17801ec","topic":"最大的优点：减少了程序段的调入调出","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"4719ad61-a239-4239-84bd-5a8be2ee402f","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"698b9069-2f28-414b-b878-1ad88f6187fd","topic":"无","expanded":true}]}]},{"id":"015a8a71e7e84320ef5d49e0c9","topic":"连续分配","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-44adcb444504eb.svg"},"children":[{"id":"17464934-79a3-429b-af65-ff73fe09f8ad","topic":"连续分配和非连续分配：装入","expanded":true},{"id":"656957e6-abb0-4f1e-ac05-efd7e3cd82de","topic":"内部、外部碎片","expanded":true,"children":[{"id":"6494ff7b-4f91-41ac-97a9-d3396fa6c7fb","topic":"程序使用的空间、程序申请的空间、内存总空间","expanded":true},{"id":"bd4d7230-31e5-41e0-9fa1-a030e25b4d0f","topic":"内部碎片：程序申请空间 - 程序使用的空间","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"4b05b65a-1fac-469f-8912-372954631429","topic":"外部碎片：内存总空间 - 程序申请空间","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"e9b9a98f099921b56f4b3b273e","topic":"单一连续分配","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"c48b28b2-fe52-4c16-96da-5140e5182d56","topic":"一个内存空间只给一个进程使用","expanded":true,"style":{"background":"#8EDE99"}},{"id":"d1235174-8e9f-4fb2-a6fd-4c1fe28381ca","topic":"优点：","expanded":true,"children":[{"id":"c3b4e13c-94b9-4312-b255-ddc67959ed41","topic":"简单、无外部碎片、采用覆盖技术","expanded":true}]},{"id":"0303a198-95ad-4026-b015-927d691a3eb7","topic":"缺点：","expanded":true,"children":[{"id":"7a0e07ee-51ee-47fb-b1d8-45dc215061dd","topic":"单用户、单任务、有内部碎片、利用率低","expanded":true}]}]},{"id":"21ab244e258811b31095d98cb5","topic":"固定分区分配","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"0e5b19ac17e9be2f2c603b9056","topic":"分区大小相同","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e0fa9aa5-f0b7-41ba-baa8-43056e163443","topic":"将内存空间划分为若干固定大小的区域","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"1098924386389a3f0661e907ba","topic":"分区大小不同","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"6dd29e2d-9f5e-4d9d-82d6-5a72276d217f","topic":"划分为多个小分区、适中中分区、少量大分区","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"72eb8a2eec889bd095238910c5","topic":"分区说明表","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b6af684e-53e7-4ca0-91d4-7da48b9a96c1","topic":"（分区号） | 大小/KB 、始址/KB、状态","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4b92bbcb333ad2.png","width":355,"height":174}}]},{"id":"715caeee-3ba2-4863-92c3-93407df73919","topic":"优点：","expanded":true,"children":[{"id":"0bdb43e0-d735-45fc-bc2b-ec25856e5a2f","topic":"多道程序设计、无外部碎片","expanded":true}]},{"id":"69451b99-10d0-42bd-8e7e-bc04cd9e7d7d","topic":"缺点：","expanded":true,"children":[{"id":"2bf595a6-2ff8-4d84-9056-0e17507628e9","topic":"程序太大，分区装不下","expanded":true},{"id":"f3ea31a1-9af8-4bcf-b05f-a778fce30d1a","topic":"主存利用率低，很多内部碎片","expanded":true},{"id":"8ad736a9-8be6-462c-9b0d-abc83f037f0d","topic":"没有内存共享能力","expanded":true}]}]},{"id":"c01b9f76958802ff6cd1ca2ff9","topic":"动态分区分配","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"c544a886-3a53-4884-bb3d-d8d3a8c2a82f","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-579e139db575fd.png","width":584,"height":181}},{"id":"200972e366faa14a3aff3a9c26","topic":"记录存储内存使用情况","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b13b6eb6-fe3e-4ca9-a8d1-23428dcec8b3","topic":"内存分区链、内存分区块","expanded":true,"style":{"background":"#8EDE99"}},{"id":"43c53dcf-2ca9-4a7d-b582-d27ad9ea2811","topic":"分区表","expanded":true,"children":[{"id":"d8ff861d-2f8b-4a08-aef9-7ee85c25909f","topic":"(分区号) | 大小/KB、始址/KB、状态","expanded":true}]}]},{"id":"8e5a765b5bb9283108cf98bfd6","topic":"分配回收","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b9b8ae620c9901e00e82ab56f2","topic":"动态分区分配算法","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"5513bb3e-fa4a-4526-bb99-427df688483e","topic":"首次适应","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"156b7662-dafa-45f2-b822-6458fcb06c1c","topic":"找到第一个满足的就行","expanded":true,"children":[{"id":"c524667d-50e8-4cdb-a39a-9f0bfae3c2b2","topic":"最好的","expanded":true,"style":{"background":"#FDD834"}}]}]},{"id":"2cdb224d-a0c1-4cc6-b57f-afc2c4ab5186","topic":"最佳适应","expanded":true,"children":[{"id":"26200bee-5fd5-40c3-9baa-4e62ec2f3b2c","topic":"找到最小满足的一个（排序）","expanded":true}]},{"id":"c444c774-2246-4a30-b2ee-de6843dbe7db","topic":"最坏适应","expanded":true,"children":[{"id":"ec631b86-d855-4e5c-b5db-ca3f32deed66","topic":"找到最大满足的一个（排序）","expanded":true}]},{"id":"4815698d-42a8-4f4a-9700-03fe814723f3","topic":"邻近适应","expanded":true,"children":[{"id":"d77f3255-b399-48c1-afd5-ab91d2851d4f","topic":"首次适应 + 指针不回溯","expanded":true}]}]},{"id":"989a5ebdca498b3201ee29e584","topic":"回收（4种）","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"109fc406-2f6d-4646-9d84-6615d75d2b3f","topic":"紧凑技术","expanded":true},{"id":"46a4d71e-68dd-454c-b1b5-884cf9a2eee1","topic":"分区前面有一块","expanded":true,"children":[{"id":"9e734b37-bf4e-48cd-94a4-cfde15d72282","topic":"改前一块的大小","expanded":true}]},{"id":"ede76971-313e-476f-bb34-4a96d53df1ce","topic":"分区后面有一块","expanded":true,"children":[{"id":"862af899-1993-4102-aeb0-71ab315e8c96","topic":"改后一块的大小 + 始址","expanded":true}]},{"id":"c22884e0-6b04-4e88-88f6-b8dcd981917b","topic":"分区前后都有","expanded":true,"children":[{"id":"19e63fde-4997-43a1-a999-4adc543da910","topic":"合并前后两块，改大小","expanded":true}]},{"id":"7f440c47-0aad-4151-bad6-ea6124491ac6","topic":"分区前后都无","expanded":true,"children":[{"id":"2a7c6fff-28bf-4d2f-b158-4c22d1c48295","topic":"新增一块","expanded":true}]}]}]},{"id":"b433cbd3-44ca-4b79-942b-253b0fa77c17","topic":"分配流程：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"d16726f4-9926-4577-a069-68ca1a2b1848","topic":"系统在初始化后除操作系统占据一部分内存外，其余部分都是【自由空间】。作业申请内存时候，OS分配一个大小相当的内存过去，将作业创建为进程，在作业运行完毕后，在释放内存","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"9a175622-f913-475c-be0c-18871a100367","topic":"申请内存阶段就是装入阶段","expanded":true,"style":{"background":"#FFABD5"}}]}]}]}]},{"id":"3e0934092d99ff80b3a90a94b0","topic":"非连续分配","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-618e04089e020a.svg"},"children":[{"id":"0f0a290dfa0a861c48692be320","topic":"概念","expanded":true,"children":[{"id":"2c7bc02c6158ec2b115e1a5dc1","topic":"页、页表、页框、页帧、块、页面、内存块、物理块、物理页面、页表项、段、段表、段表项","expanded":true,"children":[{"id":"6a28bb0b-c5f5-4407-9e21-0cffc541f634","topic":"对应关系","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"948ceaaa-74f3-4481-8c1d-cfacbe83de3d","topic":"进程的","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"9b4ca701-1af1-42ac-b60a-aa28175eeb16","topic":"页、页面","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"5d081b70-2dd6-4b3b-8625-0af11657d874","topic":"内存的","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"de7ccec2-f6b7-4417-8ce7-b142db23df80","topic":"页框、页帧、块、内存块、物理块、物理页面","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"33e3b502-3f25-45ff-a907-065c6d2a7230","topic":"外存的","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"edc04e71-8332-4a4f-949d-8b98de6248ae","topic":"块、外存块","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"b1a658cf-d939-4b20-a1e0-877f6d79d894","topic":"其他的","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"9d3d77cd-4ebb-428f-bff4-840697c75ff8","topic":"页表、页表项、段表、段表项","expanded":true,"style":{"background":"#8EDE99"}}]}]}]},{"id":"3916a7a1-aecd-427a-be83-3c9088363088","topic":"非连续分配：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"6f534506-891b-4048-8e91-39371967dd17","topic":"把主存空间划分为大小相等且固定的块，块相对较小，作为主存的基本单位。每个进程也以块为单位进行划分，进程在执行时，以块为单位逐个申请主存中的块空间。","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"bf9bfcbabb59f5d9f20f4b917d","topic":"分页存储","expanded":true,"children":[{"id":"0898b22d9bb902ed7059291130","topic":"基本分页存储管理","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"7e908827-f8dc-4609-aab7-6a9566cea26d","topic":"原理","expanded":true,"children":[{"id":"53da1465-a769-41cc-80a0-ab0179538f0e","topic":"把内存划分为数个大小相同且固定的块、块相对较小、作为主存的基本单位","expanded":true},{"id":"fb8c92fc-4dc6-4fac-bd57-09d98918e675","topic":"页面和内存块的完全大小相同","expanded":true,"style":{"background":"#FF9595"}},{"id":"a0c1710f-82b7-496a-bed9-1de229d505d0","topic":"图示","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-17ae3f9ffba064.png"}}]},{"id":"7e3f5460-8146-4ba5-b2f0-4d22325872c1","topic":"转换","expanded":true,"children":[{"id":"27f6d8ac-527b-4f59-b842-247320f0afb7","topic":"内存总大小为 4GB, 内存块大小为4KB, 所以内存中一共可以有 2^20个内存块，内存块编号为0 ~ 2^20 - 1","expanded":true,"children":[{"id":"1d1d5404-6e58-4c4f-a7f5-9dbabc747610","topic":"由此可知【页表项中的块号】至少需要20bit来存储，即至少需要3B来存储（如果需要填充为B）","expanded":true}]}]},{"id":"fc6537c2-7610-473c-8d2a-a56c04af8f89","topic":"数据结构","expanded":true,"children":[{"id":"f7ba8dade559dc9b25484bd533","topic":"逻辑地址","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"9fc7381a-a8c7-4521-aa0a-f0bff7b35e20","topic":"页号、偏置值","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"6d02a6fd-c64a-4e16-b281-cf181af9f4aa","topic":"硬件划分","expanded":true,"style":{"background":"#FF9595"}},{"id":"66f4ff02-293f-47e8-912f-53a8826b3d56","topic":"链接后产生的","expanded":true},{"id":"c085d5ab-f30b-4734-9cb7-0b36f8b735f1","topic":"使用2^n B来设计页面大小，很方便快捷","expanded":true,"style":{"background":"#FDD834"}},{"id":"d1d7660d-d186-411a-8a32-fc70f3e4b562","topic":"按字节寻址 -> 偏置值W的bit数就为 n","expanded":true}]}]},{"id":"890a3eb87a68f0d96337e9552a","topic":"页表寄存器（PTR)","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"fe55c4e3-c640-4f75-9e9d-3a00d52d6378","topic":"页表始址、页表长度","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"12e920d51b2b8b3312629a0ab9","topic":"页表项结构","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"02acdaf2-a473-4c06-9ece-a941352c4926","topic":"（页号）块号","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"a56aa4f8-fa21-4d61-a637-183ca2268a39","topic":"页号并不占用存储空间","expanded":true,"style":{"background":"#FDD834"}}]}]}]},{"id":"3ac87a67a4a8889f1ccf48debf","topic":"基本地址变换机构：\n得到一个逻辑地址，操作流程","expanded":true,"children":[{"id":"a7a0216a-dc15-4ba0-bcec-f94dfc7fb0a1","topic":"对逻辑地址A的页号先进行越界检查，确认不会中断，与页表始址进行相加（块号地址 = F + P * 页表项所占地址个数），就可以对应到块号了。物理地址 = 块号 拼接上(concat) 偏置值","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-649fe39bf406bb.png","width":454.22,"height":257.12},"children":[{"id":"91b42b22-50e6-45d4-88f4-55eb2636d677","topic":"两次内存访问","expanded":true},{"id":"97285000-4181-4d36-9d98-74303a7ee9eb","topic":"一次越界检测","expanded":true}]}]},{"id":"9bde9d86-3a92-430f-b1f6-3561eb4bb1b0","topic":"访问内存次数：","expanded":true,"children":[{"id":"0d8b5549-1d47-42eb-9bda-1bce490857c6","topic":"两次","expanded":true,"children":[{"id":"388120c7-61da-4c1f-94ef-462c71da3d70","topic":"访问页表","expanded":true},{"id":"efb82ad3-7353-4454-90bd-8eba8bcbdd06","topic":"访问内存中对应的位置","expanded":true}]}]}]},{"id":"a958e870be1a178c4b5e4b339a","topic":"快表分页存储","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"6b8b75fb-70ba-4cfd-bbe2-fea3d1405aae","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-41a3213e67c6fb.png","width":457.89,"height":259.1}},{"id":"c3e9273abf0a6ba38b33bb4b75","topic":"多了一个TLB","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"604a1c06-db9e-4ee6-82e0-ef1b08117747","topic":"相联存储器、快表","expanded":true,"style":{"background":"#FF9595"}},{"id":"355895f3-83e8-47d8-904f-10da6fddb992","topic":"快表中存储了页号 + 对应块号","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"d99260eb-7deb-4d55-b6dd-72b7728a9505","topic":"像计网中的路由器的特殊路径一样","expanded":true,"style":{"background":"#ADADAD"}}]}]},{"id":"c85b1d9aae3b152919e65947b5","topic":"命中率","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"8d163750-1917-4105-8684-c6aa0e00a137","topic":"90%左右","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"2bf3b15f-1c33-4558-969c-9a673d878f86","topic":"就有90%的访问只需要访问一次内存即可","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"f81ab60eacb818bcd5d7584a2e","topic":"操作流程的改进","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"4e474c19-f836-4050-8459-71a7eb37788e","topic":"进行越界判断，再查快表。如果快表中没有，查慢表","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"607505b2-2eac-4319-ba6f-db69c14b16e7","topic":"也可以快表慢表同时查","expanded":true}]}]}]},{"id":"641a6f081a891f62fcb92ab9ca","topic":"两级页表\n（升级版）","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"e7186315c1ea2a5707b0ca5f64","topic":"逻辑地址结构","expanded":true,"children":[{"id":"c1684735-923b-48a3-9780-199cdac8326c","topic":"一级页号、二级页号、页内偏移","expanded":true}]},{"id":"a6c9fcf13c08588b7c2c480c79","topic":"第一级页表的名称","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"6cd7aab8-0f8c-4280-8f57-9ece32c39a84","topic":"页目录表/顶级页表/外层页表/一级页表","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"a17a9801-2ef6-4a31-ab7d-a1f75ce27042","topic":"第二级页表的名称","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"332dcc10-a691-4742-afb5-2efa43dfaa8b","topic":"二级页表","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"59c8b0d18a48ccaada2c1923c6","topic":"操作流程","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"f7fea008-c39c-47c8-82bc-d046c813b32b","topic":"获得逻辑地址的一级页号，一级页号进行溢出检测，通过访问一级页表找到对应的二级页表对应的块号。然后先对二级页号进行溢出检测，通过二级页号在二级页表中查找内存块号。找到内存块号就可以访问啦","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-55268c1b2cac58.png","width":382,"height":296},"children":[{"id":"9e9eacde-54bf-43d0-b5b1-31293cbe966e","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-5867739b404331.png","width":496.46,"height":279.59},"children":[{"id":"84653115-a8ed-4207-a8f8-2dd198c905d1","topic":"三次内存访问","expanded":true},{"id":"d1ba3098-0c5e-41bf-a1f8-b17c064fcbf4","topic":"两次越界查看","expanded":true}]}]}]},{"id":"3ee22c7f-07ce-48ea-989a-8f79ddb0cc64","topic":"特点（了解）：","expanded":true,"children":[{"id":"5f603807-a9f2-459a-9571-c0dad5a3d324","topic":"页目录表中的表项个数\n和\n二级页表的表项个数可以不同","expanded":true,"children":[{"id":"5a6733bf-3028-4439-a0a9-4e3cd217e9e2","topic":"例如：OS中一个顶级页表，一共有2^7个二级页表，每个二级页表可以存储2^9个页表项，每个页面大小为2^10","expanded":true,"children":[{"id":"345d5a62-bac6-4d4c-a573-c93b37718fc4","topic":"则逻辑地址中：页目录号为7bit，页号为9bit，偏置值为10bit","expanded":true}]}]}]}]}]},{"id":"f868db60420a5ca90b61aa1128","topic":"分段存储","expanded":true,"children":[{"id":"10699ee6e36b681949c3b8433e","topic":"分段储存和分页存储出发点上的不同","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"4575615a-6297-4f1b-81df-d3d8435ab289","topic":"分段存储：分段存储是给程序员设计的","expanded":true,"children":[{"id":"b049482a-3e1b-40a2-8cdb-cb5f383f1463","topic":"段：信息的逻辑单位，用户可见","expanded":true}]},{"id":"66f84187-e575-41e4-a4e2-2a1857d9e733","topic":"分页存储：是为操作系统设计的","expanded":true,"children":[{"id":"11907014-9e1b-43de-b22c-7ae81256ed23","topic":"页：信息的物理单位，用户不可见","expanded":true}]}]},{"id":"3d5b430aeaea3f885307691717","topic":"基本分段存储","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"bc1bf8afdeaa5fab858328ea2a","topic":"逻辑地址结构","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"b51ab082-c1ed-42cb-bcc5-2662ab9fd78d","topic":"段号 + 偏置值","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"2095b57f-ad36-4ad5-8fd0-b84c7eae1f48","topic":"段表寄存器","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"847a11d2-8614-4161-a2c5-6be9b42f0d68","topic":"段表始址 + 段表长度","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"58eba1967f1a58768136fb5a6a","topic":"段表项","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"2cb3e685-bbe1-4e1d-baf4-faa18250afa2","topic":"（段号）| 段长、始址（没有内存块咯）","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"e0994b161a1b90f599feb9066c","topic":"操作流程","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"3b7772e5-efed-4ac4-8927-b1438a5b2b2d","topic":"首先获得逻辑地址，判断段号是否越界，然后访问段表，查看对应段的偏置值有无越界，随后即可访问","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-a215c4d927f041.png","width":467.27,"height":278.92},"children":[{"id":"82eb2fc6-3c94-4ec9-ac04-47efb49fc22f","topic":"两次内存访问","expanded":true},{"id":"ae767089-59d9-49ce-a3c3-87eaa5777de1","topic":"两次越界检测","expanded":true}]}]},{"id":"603bec1f7ac88dd06ec86a9660","topic":"分段的地址是二维的（了解）","expanded":true}]},{"id":"4e9a9b5bfaa813976384d9277e","topic":"段页存储方式\n（升级版）","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"da59c2077cea5db96483184693","topic":"逻辑地址结构","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"df61f573-b050-4393-bb40-717103d6641d","topic":"段号、页号、偏置值","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"54589379-2e8d-4fc3-b86d-db12f2bb9f02","topic":"在程序员设计分段时，还是太大了","expanded":true}]}]},{"id":"4d9b529f-a968-43cf-9c7c-0ed075520228","topic":"段表项","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"fe83fc83-ca47-40b7-8e52-f6b3491e27dd","topic":"（段号）、页表长度、页表始址","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"eaca880b-400b-4d8a-8bce-6ceefbeee9ac","topic":"页表项","expanded":true,"children":[{"id":"0ac3c91c-4bba-4c16-9e01-f530f4d19664","topic":"（页号）、块号","expanded":true}]},{"id":"cd0bb0b4b53a1f8e3ef39be7a8","topic":"操作流程","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"9787a7aa-adf5-4d5b-a7c0-669b109fb647","topic":"首先获得逻辑地址，判断段号是否越界，访问段表项，判断页号是否越界，就页表始址+偏置值","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-fe3d841bf5b0a5.png","width":468.85,"height":281.99},"children":[{"id":"3a5421c0-62a4-4844-afb9-afe9877ef8c0","topic":"三次内存访问","expanded":true},{"id":"600928f7-59b8-4259-ae42-aa7270d4f52b","topic":"两次检测","expanded":true}]}]},{"id":"2cd9e8ab0e591942cfeaca65bb","topic":"引入快表","expanded":true,"children":[{"id":"a60afe16-71c1-4122-bb64-145f4fa1d09b","topic":"关键字：段号、页号","expanded":true,"children":[{"id":"a88a30cc-8664-4e71-ae35-d35b2eef5886","topic":"值：页帧号、保护码","expanded":true}]}]}]},{"id":"e35dccf7-4b17-4f36-862e-2f2a9d8b717f","topic":"采用分页/分段管理（了解）","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"2f15dd41-5525-44c4-ab1e-012be25f02ff","topic":"提供给用户的物理空间 = 总空间 - 段表/页表空间","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"3233cd7e-3c8e-4600-92c9-257b1a70087a","topic":"所以分页、分段无法确定要分配多少空间给用户","expanded":true,"style":{"background":"#FFABD5"}}]}]}]},{"id":"fbaed2c1-12d6-43fe-aa80-059f21b4b706","topic":"考频：超高","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"97d44ba0-1cd9-4eae-a798-b867d0765782","topic":"09、10*2、14*2、16、17、19*3、21、13大","expanded":true}]}]},{"id":"f288d13b513a0a584297c9bc19","topic":"虚拟内存","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-b46a6fdcc50657.svg"},"children":[{"id":"c8a9aeaa-142f-4d9c-b5da-b0350519aab7","topic":"考频：超高","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"b5ee95f4-4d20-45e3-8535-d9a21159d951","topic":"11*2、12、13、14*2、15*2、16*2、19、20、21*2、22*2、09大、10大、12大、15大、17大、18大、20大","expanded":true}]},{"id":"dd1b92a7-d598-402c-a57e-e31f2d6ebee0","topic":"为什么使用虚拟内存","expanded":true,"children":[{"id":"d7145062-3308-48df-bc83-4f5c4f4ac9d6","topic":"若同时运行的进程太多，则需要很多的内存，当一个程序没有内存空间可用时，那么它甚至无法运行。 所以，在物理上扩展内存相对有限的条件下，应尝试以一些其他可行的方式在逻辑上扩充内存。","expanded":true}]},{"id":"1398909a-2147-4098-bc94-14cf5c49e77e","topic":"虚拟内存的空间大小约束","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"ff647a53-943f-42f7-bef9-5e4ebfaa9a4c","topic":"实际容量 ≤ 内存+外存","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"081c4bf7-e2e3-4f7a-9ece-d4fcdab7b587","topic":"硬件硬性要求","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"33082e69-32db-4335-b31e-0ad239f87215","topic":"最大容量 ≤ 计算机地址位数容纳的最大容量","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"5d060b10-bf38-478f-ac02-871d6d2b5472","topic":"例如32位地址系统，虚存最大为2^{32} B","expanded":true,"style":{"background":"#FDD834"}}]}]},{"id":"40040055-c539-4728-a728-cc6db95e324c","topic":"虚存的好处和缺点","expanded":true,"children":[{"id":"35b26589-aede-45a7-8cba-debcdeba9a4c","topic":"好处：使用了外存空间扩充了内存空间，通过一定程度的换入换出使得整个系统在逻辑上能够使用一个远远超出其物理内存大小的内存容量","expanded":true,"style":{"background":"#8EDE99"}},{"id":"59754a1e-75e9-447c-a6b0-ed39dbcdc115","topic":"缺点：虚拟内存技术调换页面时需要访问外存，会导致平均访存时间增加，若使用了不合适的替换算法，则会大大降低系统性能","expanded":true,"style":{"background":"#7986CB"}}]},{"id":"cbb9bc7b18abee739bf619e0d4","topic":"虚拟内存的基本概念","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"30a82717f1e81c02cf3fbb8339","topic":"传统存储管理方式","expanded":true,"children":[{"id":"a089990ab098aab8a5d6493bef","topic":"一次性","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"6a9eb83f-19a8-49f6-a219-abc69382e1dc","topic":"程序一次性全部装入内存","expanded":true,"children":[{"id":"89755a3b-55fa-49b8-ac0d-e6f7c922b7dd","topic":"程序大，运行不了","expanded":true},{"id":"3c604d8b-ef7d-4f32-88a9-4f526765c75f","topic":"程序多，并发度低","expanded":true}]}]},{"id":"1838a61a6da8ed4ebfb54abf03","topic":"驻留性","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"e0544428-d697-41d9-bb53-7471d6723a88","topic":"程序直至运行结束才会被换出内存","expanded":true}]}]},{"id":"775b20d6a339abbb331bf9d1cc","topic":"局部性原理","expanded":true,"children":[{"id":"b969631e0f7aaf572fe41aef56","topic":"时间局部性","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"fc778842-844a-4611-a2eb-dbcbf6028729","topic":"某条指令被执行，不久会再被执行","expanded":true}]},{"id":"7b99c38f23da79b7f951f8612d","topic":"空间局部性","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"0717ffb0-6199-42c4-906f-07c6799128e6","topic":"访问了某条指令，其相邻的代码/指令也会很快被访问","expanded":true}]}]},{"id":"50685c74bbd91e52058d68ba34","topic":"虚拟存储器的定义和特征","expanded":true,"children":[{"id":"9b90abed-9371-4b8e-8aa7-677d7d8e8932","topic":"特点：","expanded":true,"children":[{"id":"28764122-59c5-4cc2-bde5-73956a7f2ad1","topic":"分内余外","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"6246d9c0-1b97-4790-94a9-feca8e793800","topic":"部分装入内存，其余留在外存","expanded":true}]},{"id":"bb2e9cec-1b7f-493a-abe9-ba37a084e698","topic":"内需调入","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"c246cd04-bb6c-40ae-af63-1a41bfa30ad7","topic":"程序执行过程中，所访问的信息不在内存，需要OS把信息调入到内存中","expanded":true}]},{"id":"04684835-ab7f-4b8a-89f9-c3f5a72f5f48","topic":"空闲调出","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"d55bf7f2-a900-449e-a926-a22c5efa5d15","topic":"OS将内存中暂时不需要的内容换出到外存","expanded":true}]}]},{"id":"081a34b7592bafa9b6a069a9e4","topic":"多次性","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"17444d88-461c-48e8-9d7d-5f870405c63c","topic":"作业无须运行时全部装入内存，可以分多次完成装入","expanded":true}]},{"id":"c42a2998c2d8045e8b835a10d9","topic":"对换性","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"8cd7ff64-84c6-46ce-8991-bb740bfa5946","topic":"作业无须常驻内存，可以在运行过程中换入换出","expanded":true}]},{"id":"97aa3a902a5a9ef437807a1e44","topic":"虚拟性","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"e65b9ca3-38cf-4b70-877e-375b5f64da4f","topic":"逻辑上扩充内存的容量","expanded":true}]}]},{"id":"44db023d07ab0edda1c259d39a","topic":"虚拟内存技术的实现","expanded":true,"children":[{"id":"71d85c3568eb378c63371b090d","topic":"要建立在","expanded":true,"children":[{"id":"651b24d2-0e13-41e0-b38e-3ef3aa7cc14b","topic":"非连续分配的情况下","expanded":true}]},{"id":"bd99231a49bb7adb5546d9e4ca","topic":"三大虚拟内存实现方式","expanded":true,"children":[{"id":"8c060148-60be-4d71-8573-4c881b912511","topic":"请求分页存储","expanded":true},{"id":"3c80ad87-deb3-4973-8b0b-3f7e62485a72","topic":"请求分段存储","expanded":true},{"id":"4612f6a1-880c-4e10-bf77-9906dbc04f13","topic":"请求段页式存储","expanded":true}]},{"id":"918858f5667b7368c4718a9c3e","topic":"需要的四个硬件支持","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"2e5eb8b9-7079-45c9-93e4-a870326d5272","topic":"一定的内外存","expanded":true,"style":{"background":"#FDD834"}},{"id":"df370509-5b8f-48fa-b966-c144ce21ae21","topic":"页表/段表数据结构","expanded":true,"style":{"background":"#FDD834"}},{"id":"4eb24296-f3eb-4c5e-83be-291881cfa2bf","topic":"中断机制","expanded":true,"style":{"background":"#FDD834"}},{"id":"48244d63-04ad-4369-b074-2fc673ab3267","topic":"地址变换","expanded":true,"style":{"background":"#FDD834"}}]}]}]},{"id":"8c39bb9faf5a47151a18082780","topic":"请求分页管理","expanded":true,"children":[{"id":"6f7b6d8bb3f908a7b048bbab7c","topic":"页表机制","expanded":true,"children":[{"id":"af16649f-b034-473f-b1b3-ded2b016ba09","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-b0268e0c8e63f5.png","width":699,"height":120}}]},{"id":"017a8ed2569a9589dc217bc209","topic":"缺页中断机构","expanded":true,"children":[{"id":"984390d3-487c-47a7-92b5-7501e59d85cd","topic":"内存有空闲块","expanded":true,"children":[{"id":"41f6a616-4ed7-40a5-9bb2-d848813c3b24","topic":"直接分配空闲块给缺页部分，修改【页表】","expanded":true}]},{"id":"e1e63d4b-eada-4173-abb0-89a80aa71cfc","topic":"内存无空闲块","expanded":true,"children":[{"id":"1a590755-5152-4864-8781-5b8a57afffa8","topic":"通过算法淘汰某页","expanded":true,"children":[{"id":"085c5da7-4fb5-4fe6-8f57-897773b17273","topic":"【若被修改了，写回外存】","expanded":true,"style":{"background":"#FF9595"}},{"id":"e9641430-9227-4b12-b98b-871677a4a9ee","topic":"【若该页也存在于快表中，一并删除】","expanded":true,"style":{"background":"#FF9595"}}]}]}]},{"id":"6469dbea8008af87d24cc81d00","topic":"地址变化机构","expanded":true,"children":[{"id":"950329fb-f15e-497b-afec-3f50f4cde1ae","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-7002a53a7a17e4.png","width":560.31,"height":464.88}}]}]},{"id":"a5a9c6a8a4bb3f66aec18b693a","topic":"页面分配策略","expanded":true,"children":[{"id":"9b3a159d7afb48d0b930ebbd6e","topic":"调入页面的时机","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"48fb73a6e7d8cb36856f9b8a38","topic":"预调页","expanded":true,"children":[{"id":"03c1feb8-695a-44ba-a1d3-af3ddc9903e4","topic":"根据局部性原理，一次调入若干相邻的页","expanded":true},{"id":"5a1b97b5-e3c4-4711-b410-d4fb9c355012","topic":"成功率不高，进程首次调入时，由程序员指定预调页","expanded":true}]},{"id":"20cb031b32eb60861f887b3243","topic":"请求调页","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"917f83be-db4e-4619-8bea-b670e08557f0","topic":"运行时进行调页","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"dd1b7c26f758cbc4bbee6af76a","topic":"从何处调用页面","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c50bdf11fa7ba5f09e2e69e257","topic":"外存结构","expanded":true,"children":[{"id":"2e2b8af0-3211-4c01-a945-b9a46be82304","topic":"对换区 + 文件区","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"807d42ad-3cd7-4622-adbb-c30ccdf9409a","topic":"对换区是连续分配","expanded":true},{"id":"d0080bd3-002c-4db7-bf09-e57f25233a14","topic":"文件区是离散分配","expanded":true}]}]},{"id":"5cbabb2cd2f9886025453a88c7","topic":"系统有足够对换区","expanded":true,"children":[{"id":"627d922e-03fb-4f7d-b111-c99d49bc1c51","topic":"直接 内存 ↔ 对换区","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"92c85562c958a7968a9fbb38ea","topic":"系统没有足够对换区","expanded":true,"children":[{"id":"4219952d-d4c7-4bfa-a970-346a9b481691","topic":"不会被修改的：文件区 → 内存","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"88920ee2-5989-4ecb-a753-fecd74e62a1a","topic":"会被修改的：对换区 ↔ 内存","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"a60928c16c28fe2cc8b188a8d0","topic":"Unix方式","expanded":true,"children":[{"id":"1f8d59e4-38e1-44b0-b18b-836013187f5e","topic":"首次都是 文件区 → 内存","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"77aa0fa7-13b8-459c-a809-60d5b8b7ae44","topic":"其余 对换区 ↔ 内存","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"b9c7757e-bb7b-4334-9c8a-4346f4e88709","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-acb501c3ef5b6a.png"}}]}]},{"id":"41e99203137b9f17ab18e9e3c8","topic":"驻留集大小","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"5d4b3f29-12b2-4e01-9552-6381865ddd9f","topic":"驻留集：","expanded":true,"children":[{"id":"8c7e1950-8ab1-4849-81cb-dfbef019c25c","topic":"分配给进程的物理块大小（OS概念）","expanded":true}]},{"id":"6a9b982cf9daf0674cb03b0a82","topic":"固定分配 VS 可变分配","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"4c03d1c3-d477-4b78-b4b4-6cdf8c5e62e7","topic":"固定：每个进程的驻留集刚开始就确定","expanded":true},{"id":"94630b40-82fd-4ed8-827d-33ab78208638","topic":"可变：每个进驻留集是可变的","expanded":true}]},{"id":"bd5ade1bf9abb09a6b36bb4f59","topic":"局部置换 VS 全局置换","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"692f50f6-ecef-44d3-be14-ac5134714eaa","topic":"局部：缺页时，进程先自己进行页面置换，OS不干预。根据进程的缺页率，OS再进行空闲块分配的","expanded":true,"style":{"background":"#8EDE99"}},{"id":"8c6dbb49-f6b1-4919-a387-1b56e02a4616","topic":"全局：进程缺页，OS直接送一块","expanded":true,"children":[{"id":"62511c65-e684-4457-8f49-b464e841899e","topic":"如果没有空闲块，就选择”未锁定”的页面置出外存","expanded":true}]}]},{"id":"14d7bee3-4a1c-44e2-9e55-c827775100ea","topic":"联合：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"b75e9ec2-136c-4c88-b3c1-73e7a8b8edfe","topic":"固定分配局部置换","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"b0a6e87a-df0e-48f4-93d6-1cc3d2da831e","topic":"驻留集大小不变，自己内部置换","expanded":true}]},{"id":"887a31e2-ebd4-4855-85df-daa658531650","topic":"可变分配全局置换","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"d591147b-0a26-4687-b71b-9be3c40d04e5","topic":"驻留集大小可变，缺页就给你新的","expanded":true}]},{"id":"5e175eb7-a7b0-4ab5-8258-b93bb0d5d269","topic":"可变分配局部置换","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"331b552b-8293-470c-bbf4-fb58f7edf336","topic":"最好，灵活调配，缺页率高就给新的，低就拿走","expanded":true}]}]}]}]},{"id":"7e5af49068cb52341cebaad727","topic":"页面置换算法","expanded":true,"children":[{"id":"eeb9fb92fc587827575ac85561","topic":"OPT","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"74638fe2-9dab-45fc-8017-d48a8fec1adc","topic":"最佳置换算法","expanded":true},{"id":"f2d8d087-6a1f-4c60-94bd-7d9edf831b03","topic":"无法实现、找最长时间不被访问的块置换（作为算法的评价标准）","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"de6b6771e90b66a841fdfbddfa","topic":"FIFO","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"359f2dba-3724-4203-8766-d268f8b434fb","topic":"先进先出","expanded":true,"children":[{"id":"82cd4df1-08bf-4eaf-9739-522e19900162","topic":"队列类算法","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"3d406875-2c57-4f9a-8e1c-6da369afa9be","topic":"会出现Belady异常：总分配的内存物理块（内存块）数增加，导致缺页率也会增加","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"173314c0-a62a-4262-b320-e7cd99474035","topic":"实现简单，性能差","expanded":true},{"id":"35b17b00-99fd-48ad-922d-d976fc0dc5af","topic":"与首次适应进行区分","expanded":true}]},{"id":"5c9b5da8afbb377da51fdb22c4","topic":"LRU","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"670e1639-74b3-46c7-82b3-0dab49907c9f","topic":"LAST RECENTLY USED","expanded":true},{"id":"1ca2d602-3644-4f5b-b4fa-571ba43258a4","topic":"实现困难，需要硬件支持、开销大","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"ff0e3a34-f002-4315-aa11-b75c38530d9a","topic":"使用堆栈进行模拟","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"16961122-73fe-4af4-b9ba-cc222b9aac5a","topic":"堆栈上方的是新的，下方的是旧的，pop从下面pop出现，上面push进入","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-bda8d28fcac7a7.png","width":252,"height":147},"children":[{"id":"80afdf22-c2af-438d-b480-8acec2848f2e","topic":"王道的做法是底层实现的方法。（用访问字段的值来模拟堆栈）","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ce12e7ff17429c.png","width":402,"height":135}}]}]}]},{"id":"0a1b742594f94718690afb9d8f","topic":"CLOCK","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"a98f0c5a-6ebd-4326-9350-1b38eb17cd23","topic":"简单CLOCK（NRU算法）","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"543ed729-8403-411c-8f23-a21a5f44c80c","topic":"只使用访问位","expanded":true,"children":[{"id":"fefac02c-aff6-4f8d-8190-892501ad5571","topic":"第一轮扫描的时候，把访问位为0的换出，边扫描边把访问位全部置为0。进行第二轮扫描","expanded":true}]}]},{"id":"64089b81-ee28-4cbd-acc0-8f873fadfa4d","topic":"改进CLOCK置换算法","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c8317962-98c4-4726-a005-6e294334cca7","topic":"使用访问位 + 修改位","expanded":true,"children":[{"id":"09c30e4a-9f89-435e-a02f-1721c6d3a9bf","topic":"优先淘汰没有被修改过的页面","expanded":true},{"id":"4469c0d1-0be6-46bd-90f7-9ddec639d6fe","topic":"四级访问：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"eee96b98-3718-4f93-865e-aa6a6468c431","topic":"（书中的P用的A来表示）","expanded":true},{"id":"2a7eafe0-cbe0-4dfd-b3b9-7fa9fcb08b12","topic":"P = 0，M = 0","expanded":true,"children":[{"id":"a5848a40-de27-4e7c-8095-c0549b1267f8","topic":"未访问，未修改","expanded":true}]},{"id":"5934fa28-f24c-4004-9522-72e59cd5e2c6","topic":"P = 0，M = 1","expanded":true,"children":[{"id":"82429ef8-15d2-48e4-b745-f2d31113a485","topic":"未访问，有修改","expanded":true,"children":[{"id":"c4a87512-9f69-47c7-91cc-e4b60d9f8065","topic":"本次扫描结束后把所有的P都改为0，然后重复扫描","expanded":true}]}]},{"id":"7b4cb26b-b605-4358-a1cc-6320e4c7b82e","topic":"P = 1，M = 0","expanded":true,"children":[{"id":"c893a997-3585-4135-bfc7-4cbab45c145b","topic":"访问过，未修改","expanded":true}]},{"id":"d71be280-7338-491d-a3c5-386c8821fea1","topic":"P = 1， M = 1","expanded":true,"children":[{"id":"8c2af841-5404-4eec-bd6a-a50b70d1a032","topic":"访问过，修改过","expanded":true}]}]}]}]}]}]},{"id":"b938db582d79f548001f5b9658","topic":"抖动 & 工作集","expanded":true,"children":[{"id":"c71a29225a287a9806478be805","topic":"抖动定义","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"1d189549-b5ad-4a60-9df4-01657d802a6a","topic":"刚换出的马上要换入主存，刚换入的马上要换出","expanded":true,"style":{"background":"#8EDE99"}},{"id":"3db3720f-267c-446e-93f7-5a898c1d0f46","topic":"产生原因：","expanded":true,"children":[{"id":"f137e553-bd42-41a7-8717-3e21abd0b2bf","topic":"某个进程频繁访问的页面数目高于可用的物理页面帧数","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"432bd8ea-8a1d-434d-8635-7ce2064bdd2a","topic":"解决办法：","expanded":true,"children":[{"id":"c57c5ab1-dd8c-4e56-a5b0-03eb7a738201","topic":"工作集","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"cde89388ccb88e7a1fed9bb214","topic":"工作集W和时间t和工作窗口大小delta","expanded":true,"children":[{"id":"6ad809ed-cd9b-4292-b348-93584727d289","topic":"基于局部性原理，OS实时跟踪进程，用最近访问过的页面来确定工作集。例如在t1时刻，工作集窗口大小为5，窗口内的页面是2, 3, 5, 3, 2，此时工作集为{2, 3, 5}","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"cf133367-a593-4ee4-934a-694c758eb2bb","topic":"随后操作系统为进程分配【 > 工作集的驻留集】大小，就会保证不抖动","expanded":true,"style":{"background":"#8EDE99"}},{"id":"afdd5e73-4b96-4c65-b711-bf7a95d74dd3","topic":"拓展：","expanded":true,"children":[{"id":"10382889-fb44-4192-b2a1-ec6dbd7cf9d8","topic":"有些OS会根据工作集来设计页面置换算法，根据进程近期访问的页面来确定换什么页面","expanded":true}]}]}]},{"id":"942a39292588c399aedbe975de","topic":"工作集和驻留集关系","expanded":true,"children":[{"id":"36301029-6b94-49f9-b048-98ef2aae4397","topic":"工作集  < 驻留集","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"21bda5ad-1d65-4aa4-a26f-5579a3e03704","topic":"内存共享、内存映射文件","expanded":true,"children":[{"id":"b7e7cb51-eaa6-4626-8f62-c46b32e22ff3","topic":"页框分配：","expanded":true,"children":[{"id":"877c120d-b885-4fe8-acc1-6832e14e2c47","topic":"即页面分配策略，连续、非连续分配","expanded":true}]},{"id":"fd0d8788-c878-4dca-882b-8b2edeb05880","topic":"内存映射文件：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"d1984a29-3ffd-4a55-b10d-a4a5e6b5a855","topic":"mmp, Memory-Mapped File","expanded":true,"style":{"background":"#8EDE99"}},{"id":"9ff779f6-031a-4b59-aa1a-d232cf35c2a1","topic":"通过内存映射，使得多个进程的某一个虚拟进程地址区域对应内存中同一个物理地址区域","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"b68a9e7c-bafb-44a2-9e75-72b3f1937b00","topic":"虚存性能因素：","expanded":true,"children":[{"id":"293f8f1f-3303-4081-9c62-ed1f0732435e","topic":"缺页率是影响虚存性能的最主要因素","expanded":true,"style":{"background":"#FF9595"}},{"id":"543734e4-9001-4bcc-b7ea-5356cf1f683d","topic":"提高性能的办法","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"b72b0868-716e-462f-82e6-470538e4b145","topic":"设置好页面大小","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"44fc2195-82d1-49ee-bb2e-c0c3f1a15496","topic":"太大会增加内部碎片","expanded":true,"style":{"background":"#FDD834"}},{"id":"49ab240f-b7de-4b9d-a6ce-6433f44ff2b4","topic":"太小会使得缺页率高、页表过长","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"bda8358e-81d4-4489-b5bc-16542fa29172","topic":"设置好工作集、驻留集","expanded":true,"style":{"background":"#FDD834"}},{"id":"9edfcc5c-6332-4999-adef-724acea664a7","topic":"设置好LRU、CLOCK置换算法","expanded":true,"style":{"background":"#FDD834"}},{"id":"361ea049-f48f-4bab-99dc-909959cf04bb","topic":"提高程序的局部性","expanded":true,"style":{"background":"#FDD834"}}]}]}]},{"id":"27fa73b7-d73e-4e72-b95d-96f578e22645","topic":"地址翻译：","expanded":true,"children":[{"id":"f8ffa3cd-5b90-4602-9926-163496dd7126","topic":"详细看计组","expanded":true},{"id":"3ec5db2f-250f-4321-bbf0-ac8e1e3b84c2","topic":"虚地址 -> 物理地址","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-d5d5e28ef67eb4.png","width":375.09,"height":362.19},"children":[{"id":"d202c3dd-525d-4a24-8e3e-39673822f93a","topic":"物理地址 -> 数据","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-08d30e6e093df9.png","width":360.47,"height":366.93}}]}]}]},{"id":"6fc325be-bd1b-4c59-a8b2-8a55d0d1ac2f","topic":"END","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-7989069c498fc7.svg"}}]},"relations":[{"id":"c272876f-4e34-4205-aeeb-e78525f27073","from":"72eb8a2eec889bd095238910c5","to":"1098924386389a3f0661e907ba","bidirectional":false}],"summaries":[{"id":"8b14ec94-0442-4d20-b1a3-c967c7782839","parentId":"d5ab1655-083b-447e-8cf9-6655822057bf","start":0,"end":0,"label":"ci,so,exe"},{"id":"2d2297d4-764d-4a66-a9aa-ef72b0ddaec8","parentId":"88bbab02278b0a1accecd925e1","start":1,"end":2,"label":"只有装入到连续地址空间中，不能修改"},{"id":"58e3d97e-f56a-46ee-8e18-4a1c020a067c","parentId":"88bbab02278b0a1accecd925e1","start":3,"end":3,"label":"不连续空间，装入部分代码即可运行，动态分配内存"},{"id":"539a006f-404d-4e73-ba47-bc4c7e541d4a","parentId":"9e9eacde-54bf-43d0-b5b1-31293cbe966e","start":0,"end":1,"label":"如果是N级页表，则为N+1次内存访问，N次越界检测"},{"id":"eaa1d7ef-eb25-4dce-8214-0da9aad057a8","parentId":"1398909a-2147-4098-bc94-14cf5c49e77e","start":0,"end":1,"label":"需要两种都满足"},{"id":"e41fd047-7a15-4e4d-8be9-95b1be3a39c3","parentId":"bd99231a49bb7adb5546d9e4ca","start":0,"end":2,"label":"与非请求模式的区别：采用了虚拟内存的技术，不需要把页/页面全部都先放入内存中，而是在运行中检测到缺页再去外存中读取"},{"id":"99c0fa44-6f26-4272-8f23-2d6e2fb4f63c","parentId":"4469c0d1-0be6-46bd-90f7-9ddec639d6fe","start":3,"end":4,"label":"如果会搜到这里，P其实已经更改为0了"},{"id":"ffef5e98-a203-42a0-9f61-cd7ff744955b","parentId":"b68a9e7c-bafb-44a2-9e75-72b3f1937b00","start":0,"end":0,"label":"TLB、Cache命中率都没有这么主要"}],"boundaries":[{"id":"0dbe8376-c4f6-4e91-b6b7-a187d46775fe","parentId":"4e9a9b5bfaa813976384d9277e","start":1,"end":1,"label":"有变化"},{"id":"54de3fff-4c78-40ec-add4-544fc6f05cc7","parentId":"6f7b6d8bb3f908a7b048bbab7c","start":0,"end":0,"label":"在非虚拟存储的页表、段表是基本固定的，而虚拟存储的页表要实时记得要不要修改页表项"},{"id":"97964080-dcc7-42bb-82de-264975c40e9e","parentId":"1a590755-5152-4864-8781-5b8a57afffa8","start":0,"end":1,"label":"容易忘"},{"id":"60e7c849-6913-4190-944c-50898117c45b","parentId":"ff0e3a34-f002-4315-aa11-b75c38530d9a","start":0,"end":0,"label":"区别：考试做法这里面不考虑页面对应哪一个物理块。"}]}}},{"id":"35a78ebe-be39-4bce-b906-df4da3046cb5","topic":"文件管理","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/operating-systems/os-00-sheet4","expanded":false,"maxHeight":260,"doc":{"format":"brushup-mindmap-v1","id":"os-00-sheet4","title":"文件管理","structure":"timeline-h","theme":"auto","root":{"id":"9b795769bb79592d3c519ac14c","topic":"文件管理","expanded":true,"children":[{"id":"83faca6ea8cb77c218789a694a","topic":"文件","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-78cd28a5481c37.svg"},"children":[{"id":"86e95f8c4eab2aa3849f5a7262","topic":"定义","expanded":true,"children":[{"id":"80d97e9e8a68b204e3a2b985fd","topic":"信息集合、文本文档图片程序...","expanded":true}]},{"id":"844dd36a-73c2-40bb-98d9-41a6158b391e","topic":"在用户角度中：","expanded":true,"children":[{"id":"8c8d73ef-1e9e-4215-9878-e68f343449a3","topic":"OS引入文件系统的目的是可以让用户实现按名存取","expanded":true},{"id":"7f264010-bca0-4562-898f-9b7d15367830","topic":"文件系统的设计是为了方便用户的","expanded":true}]},{"id":"cb28946031d93489e9c278fe9e","topic":"属性","expanded":true,"children":[{"id":"234ea468-49d9-472a-b7c9-aaab70e88033","topic":"又称：文件元数据","expanded":true,"style":{"background":"#FDD834"}},{"id":"6e4db1c1-2216-4743-bfc8-2164b01c15dc","topic":"名称、标志符、类型、位置、大小、保护、时间、日期、用户标识 等","expanded":true},{"id":"e3688ea0c0cae07413032b716e","topic":"文件名","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"977bfdd9d82b2ed27fa238ad87","topic":"同一目录下，文件名称唯一。是用户搜索的主要内容","expanded":true}]},{"id":"68495d2cceea8f974382ca4a81","topic":"标识符","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"06c8a61a144b77f4fe52e9e39e","topic":"每个文件都由一个的唯一标签，人不可读","expanded":true}]},{"id":"c248420e3baa590be964ba95b1","topic":"保护信息","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"ecabb471da091746d631b8de89","topic":"访问控制信息","expanded":true}]},{"id":"e1fb414b9bd9c35e22abf868f1","topic":"其他属性","expanded":true,"children":[{"id":"4799823832c8ea7aee48e90d04","topic":"类型、位置、大小、时间","expanded":true}]}]},{"id":"d007deb8-2aeb-4565-8448-56dde1351f31","topic":"文件控制块、索引节点：","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"02dafd807bbbb1121281e8c4da","topic":"结构","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"7be8d73b44e9548d7dc1892272","topic":"数据项","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"73a865b1c33b52448b4c38d6c8","topic":"基本数据项","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"1569f973171bd4da11974a3ad7","topic":"原子数据，不可再分","expanded":true}]},{"id":"1bb92ba3831a1ae64e414aff8e","topic":"组合数据项","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b24b2c9a391a92db82d358dd30","topic":"多个基本数据项组成","expanded":true}]}]},{"id":"0289bf3aa9a9c6753382988877","topic":"记录","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"8698c7c1810bdd2282970a5b33","topic":"相关的数据项的集合","expanded":true}]},{"id":"24ea39b13e5a229990d7d82e97","topic":"文件","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"2b099f541fc96312fc99fa873a","topic":"记录式文件","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"bc7acbd7d598f5a7e9729aaeae","topic":"由众多记录的集合","expanded":true}]},{"id":"e1a8cdb6017ac930d83e6960de","topic":"流式文件","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"72ba7a0ec1b91236c61a387e3e","topic":"无结构文件组成字符流","expanded":true}]}]}]},{"id":"91dbde01533bcf699a9019c2db","topic":"保护","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"35fb3f4558fb3d4e27c88a6883","topic":"口令保护","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"c3ca5164550905ac3bbcb991e0","topic":"优点：","expanded":true,"children":[{"id":"836aad3f551975f834294ba219","topic":"口令开销小","expanded":true}]},{"id":"67dbecf506a9acfa08647a8f2f","topic":"缺点：","expanded":true,"children":[{"id":"972bdd92868b547692e90bf9c6","topic":"保存在内存中，很不安全","expanded":true}]}]},{"id":"7e0ad485239a3a89a39ad80293","topic":"加密保护","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"faaa8a907d2a5477d7dec8581e","topic":"优点：","expanded":true,"children":[{"id":"fc78c61b0fcb9c532fcbfb7d67","topic":"保密性强","expanded":true}]},{"id":"072b2e7554c9843ed3094b1885","topic":"缺点：","expanded":true,"children":[{"id":"ed6a031b171a22bb187a7ae7ad","topic":"编码、译码需要一定时间","expanded":true}]}]},{"id":"c68a7bbf3bea4c15dec16bb7b6","topic":"访问控制","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"aee86bbf660b53cc4e531b1174","topic":"访问控制列表：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"08688309406ac12dbea44973a2","topic":"英文：","expanded":true,"children":[{"id":"6be9f12d4ebb5d96b3571aa175","topic":"ACL","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"a4529317-31a1-498d-8a4f-7c37a95f0ee9","topic":"根据用户身份进行控制，给每个文件和目录增加ACL，规定了不同的用户的访问类型。","expanded":true},{"id":"b7f9fa700cb86831eb33882eef","topic":"【精简】的访问控制列表：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"15da136bb2ea41237895e855a6","topic":"拥有者","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"484a3da98fa95b086a7ff8a682","topic":"创建文件的用户","expanded":true}]},{"id":"bf29a3c28e988d00cf32288525","topic":"组","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"0b4990f52a79c932111d1a1941","topic":"需要共享文件且具有类似访问的用户","expanded":true}]},{"id":"3758e784ff19f5fc08e2aa17a4","topic":"其他","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"72dbb854f049b4603f577ba625","topic":"系统内的所有其他用户","expanded":true}]}]}]},{"id":"6a58f57a73db57046a675b73ce","topic":"缺点：","expanded":true,"children":[{"id":"d8686039872b05bd29adab0024","topic":"内容太多，使用精简可以解决问题","expanded":true}]},{"id":"25e7d88e-1cf6-4d1d-9989-d72c436db8c6","topic":"相比加密保护保密性更差，但更灵活","expanded":true,"style":{"background":"#FFABD5"}},{"id":"7d4c94ad-d223-480b-b3fc-61e3f26b211c","topic":"访问文件的限制因素：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"a5a456d7-10a8-4869-a5ba-6477a2c8262c","topic":"用户访问权限 + 文件属性","expanded":true,"style":{"background":"#FFABD5"}},{"id":"ab6100b4-845a-426b-9629-ad16d966dc8e","topic":"用户优先级与能否访问文件无关","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"d556f7aa-292d-441d-be3a-92585a893f2a","topic":"系统级安全管理：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"ef26ae97-0ac2-4eba-9a40-a5b19396d6e1","topic":"登录注册","expanded":true,"style":{"background":"#FFABD5"}}]}]}]},{"id":"1a0bed88-ae3c-471c-a546-0e675f842d65","topic":"文件操作","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-12567a48de67cd.svg"},"children":[{"id":"01958919-e319-4864-8720-3c640e3f5709","topic":"最后看看","expanded":true},{"id":"a159ea533268cfea82c588f9e1","topic":"创建","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"e01a4dae-0c93-4e5a-8333-7229fed138ef","topic":"从外存中找到文件对应大小的【磁盘空间】","expanded":true,"style":{"background":"#FFABD5"}},{"id":"9f3ed887-d852-4629-8ad1-c2fa706c1433","topic":"创建该文件对应的【目录项】","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"6adb64ef12091b5ffc8a891168","topic":"删除文件","expanded":true,"style":{"background":"#0CE6CF"},"children":[{"id":"49e56a71-08e2-4660-9a8d-a83dc44d0303","topic":"如果存在其他硬链接：","expanded":true,"style":{"background":"#0CE6CF"},"children":[{"id":"ecc9ad81-4fd9-476d-a291-d175a8e1d68c","topic":"修改FCB的文件链接数","expanded":true,"style":{"background":"#0CE6CF"}}]},{"id":"a7bd75db-c1c2-41e5-b614-eb995296e694","topic":"不存在硬链接：","expanded":true,"style":{"background":"#0CE6CF"},"children":[{"id":"3f1526b5-a52b-4c37-be50-19b84ca4662f","topic":"删除文件的目录项","expanded":true,"style":{"background":"#0CE6CF"}},{"id":"7e248e1d-4de8-4208-a990-dbaaad879dc5","topic":"删除该文件的FCB","expanded":true,"style":{"background":"#0CE6CF"}},{"id":"191630d6-cd48-48e2-b10f-8d27f20430e9","topic":"释放与此文件相关的内存缓冲区","expanded":true,"style":{"background":"#0CE6CF"}},{"id":"d5613bb9-6e9b-4209-94cf-24bd74d09554","topic":"回收文件磁盘空间","expanded":true,"style":{"background":"#0CE6CF"}}]}]},{"id":"bab872b835ba14e961b59bc9d2","topic":"打开(目录)文件","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"4962c768-59fc-485c-9361-509058ba3512","topic":"主要工作：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"9fe0cdc9-3e37-4aa6-872e-637187b884b5","topic":"1. 找到文件对应的目录项","expanded":true,"style":{"background":"#FFABD5"}},{"id":"f9c37935-ebe1-4a1a-b2de-fa96116e363f","topic":"2. 把目录项复制到内存中的打开文件表中","expanded":true,"style":{"background":"#FFABD5"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-dc283c8476e364.png","width":360.62,"height":208.97}},{"id":"319b4f7c-7f7d-424f-b466-371da3734b72","topic":"3. 随后用户就可以使用打开文件表中的编号来指明要操作的文件","expanded":true,"style":{"background":"#FFABD5"}},{"id":"2af7132b-ba21-41b4-80c3-28d89de01f76","topic":"把文件目录调入到内存中（调入 --- 复制到内存中）","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"f04fa036-ae1b-420a-ba5a-ac12cd9e8bb8","topic":"指令：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"60c65550-799b-40d1-bb5c-072410a54d46","topic":"open(char* path, char* fname, int access) -> int","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"1d140726-daf5-44d5-846e-55a82d01d1c8","topic":"path：文件路径","expanded":true,"style":{"background":"#FFABD5"}},{"id":"53496c03-53c1-4a25-bd4c-7dda416bde57","topic":"fname：文件名","expanded":true,"style":{"background":"#FFABD5"}},{"id":"07159ff9-0c12-4f22-8060-f39461f347f2","topic":"access：指明了是只读、只写、读和写","expanded":true},{"id":"c5055373-496b-4930-8af6-e7a05c21a86b","topic":"返回的int：文件唯一标识符fd","expanded":true,"style":{"background":"#FFABD5"}}]}]}]},{"id":"b65b8e3ed7c8d57b59ae8a7103","topic":"关闭","expanded":true,"style":{"background":"#0CE6CF"},"children":[{"id":"1cdd6e89-49f6-4a83-942b-f54d9873b03a","topic":"回收分配给文件的【内存空间】","expanded":true,"style":{"background":"#0CE6CF"}},{"id":"989832aa-a74f-4101-a36c-3ef49ee6168b","topic":"系统中的“打开文件表“中count - 1。如果count == 0，则删除对应表项","expanded":true,"style":{"background":"#0CE6CF"}}]},{"id":"3c8800738fb968ab77b91a7483","topic":"读文件","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"4b166a25-487d-4d40-8885-5f553f518ba7","topic":"通过文件的目录结构，如果找到了文件的逻辑地址（即已经在内存中了），直接访问内存","expanded":true,"style":{"background":"#FFABD5"}},{"id":"c2a42931-bd15-4532-aa02-af8bdbc96dc5","topic":"通过文件的目录结构，发现数据不在内存中，则进程进入到阻塞态，请求调页。","expanded":true,"style":{"background":"#FFABD5"}},{"id":"53180eb7-7da6-4a3a-a4de-a1da31e991c9","topic":"指令：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"27c05fca-6e15-4bb1-85d3-42cc70f8c75d","topic":"read(int fd, int* buf, int n)","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"9039fd3f-8dc3-4e43-bdd8-cd0b74cbd06a","topic":"fd：文件唯一标识符","expanded":true,"style":{"background":"#FFABD5"}},{"id":"8516a18e-b77c-4c11-ae69-511baf0a9b49","topic":"buf：缓冲区始址","expanded":true,"style":{"background":"#FFABD5"}},{"id":"fe497668-e7a3-49d4-b1b0-665d4c73af48","topic":"n：读入的字节数","expanded":true,"style":{"background":"#FFABD5"}}]}]}]},{"id":"47b9c313ccca7108f66ed8fb1c","topic":"写","expanded":true,"style":{"background":"#0CE6CF"},"children":[{"id":"26b6cf29-73af-403d-86c5-76f6bfa4c158","topic":"找到文件、打开文件、读取文件（记事本需要显示已记录的内容）","expanded":true,"style":{"background":"#0CE6CF"}},{"id":"3907a946-edb7-4c26-bb28-0e6e02aef8e5","topic":"在内存区域中修改了文件数据后，使用write系统调用写入到磁盘中","expanded":true,"style":{"background":"#0CE6CF"}}]},{"id":"376def36-5f5a-424f-a3dc-1445c055c1ad","topic":"复制","expanded":true,"children":[{"id":"b5d93913-a8a4-46d9-93d4-426ddbe7d888","topic":"文件在同一个OS中复制时，应保证逻辑结构不变，但物理结构可变","expanded":true}]},{"id":"6828b0936bda5f0bbdb719e56e","topic":"重定位","expanded":true,"children":[{"id":"beded7f2-8fc2-4e2d-9bd0-36b2316c084e","topic":"按某条件搜索目录，将当前文件位置设为给定值，并且不会读、 写文件。","expanded":true}]},{"id":"4beb0784827bf7060f58988b5d","topic":"截断","expanded":true,"children":[{"id":"6456cf15-9494-4564-b0e3-64b6b5fbad78","topic":"允许文件所有属性不变，并删除文件内容，即将其长度设为0并释放其空间。","expanded":true}]},{"id":"05b85951-1f99-4362-9f85-7e2732256d19","topic":"提高文件访问速度","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"9bb02eb0-f9e0-46eb-9d8a-8341348a1727","topic":"下列优化方法中，可以提高文件访问速度的","expanded":true,"style":{"background":"#8EDE99"}},{"id":"a420d908-df57-40cb-b65f-9968116abdda","topic":"提前读","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"19bddae4-8e7c-45f9-a9db-ca489c5cc4b2","topic":"提前读是指在读当前盘块时，将下一个可能要 访问的盘块数据读入缓冲区，以便需要时直接从缓冲区中读取，提高了文件的访问速度","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"5a7b2724-005f-46c9-ab89-c18ccd20fbd3","topic":"为文件分配连续的簇","expanded":true,"children":[{"id":"c04a1417-5c38-4755-8331-672093c25f99","topic":"✅","expanded":true}]},{"id":"98c19640-62c3-4e25-a5b0-c5a00090f74c","topic":"延迟写","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"1f3702f6-ca31-40a7-988b-b189a606a3a1","topic":"延迟写是指先将数据写入缓冲区，并置上“延迟写\"标志，以备不久之后访问，当缓冲区需要再次 被分配出去时，才将缓冲区数据写入磁盘，减少了访问磁盘的次数，提高了文件的访问速度","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"5f9e2593-9949-4240-a189-c8ddaf819137","topic":"采用磁盘高速缓存","expanded":true,"children":[{"id":"1770a631-42a6-401d-a801-55f0c18b7880","topic":"✅","expanded":true}]}]}]},{"id":"308b616967d845df1df68b474a","topic":"文件的逻辑结构","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-feeda6963c3d0a.svg"},"children":[{"id":"a3ebcba2-191b-41d3-a9da-6efb7abe5491","topic":"文件+索引方式","expanded":true,"children":[{"id":"f26957c4-8b1d-486f-8b95-43938aeacc76","topic":"文件","expanded":true,"style":{"background":"#8EDE99","shape":"rect"},"children":[{"id":"d2c86e12-46a8-4601-8e06-bd635b67ece0","topic":"无结构","expanded":true,"style":{"background":"#8EDE99","shape":"rect"},"children":[{"id":"a320b87c-39b0-4abb-9d76-f00247bcbeed","topic":"顺序遍历","expanded":true,"style":{"shape":"pill"}}]},{"id":"6a646da1-6e15-454b-89d4-30c16b0646a9","topic":"有结构","expanded":true,"style":{"background":"#8EDE99","shape":"rect"},"children":[{"id":"88e0cb41-ed74-4b54-8e3c-361f79db9fc2","topic":"不定长","expanded":true,"style":{"background":"#8EDE99","shape":"rect"},"children":[{"id":"11f5614f-7186-4b6d-814f-3ceb1be21d87","topic":"顺序遍历","expanded":true,"style":{"shape":"pill"}}]},{"id":"53486bce-8600-486e-a753-c7ab415a2a4a","topic":"定长","expanded":true,"style":{"background":"#8EDE99","shape":"rect"},"children":[{"id":"3033e06e-b7c0-4693-b866-918c4926dd7a","topic":"链式存储","expanded":true,"style":{"background":"#8EDDF9","shape":"rect"},"children":[{"id":"3f2a1de9-4d34-4868-8b8f-fcaaf8f92645","topic":"顺序遍历","expanded":true,"style":{"shape":"pill"}}]},{"id":"a5f711d2-ec40-4f6f-90d2-5b8ba0361bab","topic":"顺序存储","expanded":true,"style":{"background":"#8EDDF9","shape":"rect"},"children":[{"id":"17c03c7b-e20d-4b38-9fa7-1bcd3936cbc9","topic":"顺序结构","expanded":true,"style":{"background":"#8EDDF9","shape":"rect"},"children":[{"id":"919d5a1b-5621-47a1-8b2a-fd3a0160e36c","topic":"以设定的关键字为key遍历","expanded":true,"style":{"shape":"pill"}}]},{"id":"a6ae278e-b78d-4386-b0c3-1123a176e2f2","topic":"串结构","expanded":true,"style":{"background":"#8EDDF9","shape":"rect"},"children":[{"id":"403842ac-a7ca-4edf-acd2-209e9e16e0f2","topic":"以时间为key遍历","expanded":true,"style":{"shape":"pill"}}]}]}]}]}]}]},{"id":"041a2430333820dcf573f82c91","topic":"无结构文件(流式文件)","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a1f84d4539bbab9938f77a256b","topic":"访问记录的方法：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"604a3865-78bf-44f8-8256-4ce8d2be59bd","topic":"遍历所有，找到其中一个","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"b5d972c40fead5e658fc29731b","topic":"例如：","expanded":true,"children":[{"id":"630964fedc0a0f8677accb49f8","topic":"源程序","expanded":true},{"id":"48db7327b9584e1089ebe997bf","topic":"代码文件","expanded":true},{"id":"bf286f0e7cfa530599eb09d896","topic":"txt文本","expanded":true}]}]},{"id":"4a89f8be9ffa120f1f7c5b716b","topic":"有结构文件(记录式文件)","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"375b77c81e797e341a1678ca0d","topic":"例如：","expanded":true,"children":[{"id":"7c1bc4fff1f93adc727fdbefca","topic":"数据库","expanded":true}]},{"id":"1888ee3003f870f9cbfe8b6b32","topic":"文件分类","expanded":true,"children":[{"id":"6afabc7711d8e1713de8fbf693","topic":"顺序文件","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"308a2d7e49289ba4a14c29c3bb","topic":"存储方式","expanded":true,"children":[{"id":"97eae00ed7a9645e4f2548f488","topic":"顺序存储","expanded":true,"children":[{"id":"c63f9809-c4d3-49e7-b1de-6e0751e0c225","topic":"物理上相邻","expanded":true}]},{"id":"385962168049deddf55fa9d727","topic":"链表式存储","expanded":true,"children":[{"id":"87af2e94-fef2-4d2e-b62e-f3264b1fc8dc","topic":"物理上不相邻","expanded":true}]}]},{"id":"4be83fe6a17867cfb0c3983b63","topic":"结构","expanded":true,"children":[{"id":"ca2aa00d341bb1c22e3a5b488d","topic":"顺序结构","expanded":true,"children":[{"id":"dd050403-d6c6-45ae-afbd-45d7b629dd58","topic":"以关键字为key","expanded":true}]},{"id":"05582d54f9e84d255575180c8a","topic":"串结构","expanded":true,"children":[{"id":"a3098788-2faa-4f5b-8505-525e1a6ec902","topic":"以时间为key","expanded":true}]}]},{"id":"148be0a1-94db-4622-a3f9-6398eaee51d6","topic":"最方便去支持视频文件的（视频是顺序播放的）","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"3fd88bd47d2a95e31c3d0969c2","topic":"索引文件","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"2d19fcb449dbf8a835beca3db4","topic":"示意图：","expanded":true,"children":[{"id":"73f005dc-fde3-4e95-948a-d726a6fc9c75","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-95cf89d0f89f34.png","width":403,"height":194}}]},{"id":"ea6b519d8a3b00a5cbdb49b424","topic":"【索引表】的物理存储类型：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"fd9ac0d254c9a324aa58ab29bd","topic":"顺序结构、顺序存储、定长的顺序文件","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c7a3113b8b8f6a.png","width":393,"height":63}}]},{"id":"ffb2fea6-f5ff-4876-b3cd-3e2acc6cda5f","topic":"索引表项：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"03b7618a-110f-4bad-9101-de5051c41fba","topic":"索引号、长度、逻辑地址（指针）","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"df45fb9d-cec3-4cd4-b87a-cb454a1e8d4c","topic":"注意此处的指针是逻辑地址，因为是逻辑结构结构","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"94e8d509e089866da21f9b1a2c","topic":"定长/不定长：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"58f85d64f6e9b2f488d2eb239d","topic":"定长可以通过 A = i * L 来直接找到","expanded":true,"style":{"background":"#FF9595"}},{"id":"b73a0f2132e9883830a2992d3a","topic":"不定长要通过 A = ∑Li + 1来找","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"f2ac51e5-7584-4034-bc31-453545e5feff","topic":"目的：","expanded":true,"children":[{"id":"7617711b-3f59-4dea-a515-c2f73c637a89","topic":"成百上千倍提高访问speed","expanded":true}]},{"id":"cdb1316a-1c6b-4c6b-9c91-28b08763dbeb","topic":"此处也可以设计多级索引（因为是数据结构），但是书上没说过","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"c2fa97369d88d6742a93c8cdf2","topic":"索引顺序文件","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"910baae0d1fbb274735a896c8d","topic":"示意图：","expanded":true,"children":[{"id":"978b75d7-b7f4-45f9-b669-2221979df03e","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c562950f4cf902.png","width":321.54,"height":162.27}}]},{"id":"2c0b878e535a056848a919818d","topic":"前提：","expanded":true,"children":[{"id":"c73cb6e2-779a-49ef-bd88-de4c7ef919d2","topic":"顺序文件","expanded":true,"children":[{"id":"cfdc6db5-61fd-4266-9d4e-82ed8a72a328","topic":"【索引文件】中的逻辑文件可以不是顺序结构的","expanded":true,"style":{"background":"#ADADAD"}}]}]},{"id":"23f9a5136c788205c63a0b1386","topic":"索引表：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"f75ee56c-f877-420f-baa4-520713dc855b","topic":"key + 【逻辑地址】","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"903812c7b61a2a212421291e15","topic":"关键字规则：","expanded":true,"children":[{"id":"295a3e70a7cbd943b322299455","topic":"组间递增","expanded":true},{"id":"d219d931bbc8397e9557b96b2a","topic":"组内无序","expanded":true}]},{"id":"366a4f482c1b7f9e9805d9c298","topic":"如果有N条记录，那么平均查找次数的提升：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"9b5ccdf3-19a0-446a-9847-da7fde2d04d3","topic":"","expanded":true,"note":"$$ AVL从 N/2提升到\\sqrt{N} $$","style":{"background":"#FDD834"},"formula":{"tex":"AVL\\text{ 从 } N/2 \\text{ 提升到 } \\sqrt{N}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>A</mi><mi>V</mi><mi>L</mi><mtext> 从 </mtext><mi>N</mi><mi mathvariant=\"normal\">/</mi><mn>2</mn><mtext> 提升到 </mtext><msqrt><mi>N</mi></msqrt></mrow><annotation encoding=\"application/x-tex\">AVL\\text{ 从 } N/2 \\text{ 提升到 } \\sqrt{N}</annotation></semantics></math></span>"}}]}]},{"id":"6f988cc392e89b2ecb0fd928c5","topic":"直接文件/散列文件","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"3c7a28f69ddab0de4e0849abd1","topic":"直接文件","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"8cf8a363-0e56-4c9b-be5f-033248ce124d","topic":"关键字本身就含有物理地址的信息","expanded":true}]},{"id":"624b1ba87e5a35a7eedcfba5f8","topic":"哈希文件","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"e3792268-33e8-42fb-a6ee-fbde7f00d3a6","topic":"使用哈希映射能够找到对应的物理地址","expanded":true}]}]}]}]},{"id":"4c6dd5ef-55f9-4c87-a8df-c758c1219fa0","topic":"逻辑结构是用户自己定义的数据结构，和文件具体的存储方式没有半点关系，和内存管理也没有半点关系","expanded":true,"style":{"background":"#EEEEEE","shape":"rounded"}}]},{"id":"446b8962d4cb45eb13d70bdcd5","topic":"文件分配方式（物理结构）","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-84a338e255dc39.svg"},"children":[{"id":"a45ea67e-9ba3-4382-9313-064d51d05ffa","topic":"考频：超高","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"b9dae4de-1a93-4c3a-b1e9-f7a0dbdd8251","topic":"09*2、10、12、13*3、14、15、17、18、20*2、14大、16大、18大、22大","expanded":true}]},{"id":"c29386cf-68f8-4183-baac-d342d558edbb","topic":"文件在外存中具体的存储方式（文件的物理结构）","expanded":true,"style":{"background":"#EEEEEE","shape":"rounded"}},{"id":"4a787732b2b98433bfd4a9d817","topic":"连续分配","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"025f49a5-e8b8-49ee-9e18-ccbb9166106d","topic":"图示","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-d1a7a0e8904f4e.png","width":391.42,"height":323.51}},{"id":"5e698a045d982b06265aaa3fcf","topic":"原理：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"15eb1e6e859a7733fb8768da3c","topic":"每个文件在磁盘上占有一组连续的块，在外存中是【连续分配】","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"4c792016f2ba055438d27aba16","topic":"目录表：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"6c08def27c293a151d4e3a3ce7","topic":"<文件名、起始盘块号、长度>","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"3e2ac4a4fe8ba411f255e9f20b","topic":"支持的访问类型：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"c5285bdee299d6792a1b5b9c5b","topic":"顺序访问、直接访问","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"1488b135e3f8d713a99c7b3833","topic":"优点：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"371adaad2f6b3999c4e0cbe1e4","topic":"寻道数、寻道时间最短","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"51e876ab-8a5c-4035-bd13-1d174feda0fb","topic":"磁盘章节","expanded":true}]}]},{"id":"555bf3a7d8293f27561c4a3a70","topic":"缺点：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"914a949d834b88f64fce09c54c","topic":"文件长度不可动态增加","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"12f9707965babb697126a9ef83","topic":"只适用于长度固定的文件","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"6b83b525-827b-448b-b6d5-88f34a8e1071","topic":"只有连续分配会出现碎片","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"1cc6c75f-d2d2-4ec5-8894-24f25642953f","topic":"谈速度时，连续分配不管是顺序存取还是随机存取都是最快的","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"adfb5a0e7a68ea353629db5cc8","topic":"链接分配","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"9e4a62bdd659fedb073cb8ce38","topic":"原理：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"c54a88c9ec8963064cb15b9784","topic":"从起始盘块号开始访问，一块一块的找，采用离散分配的思路查找文件","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"2e3ae5b4710b180c2efe28f8db","topic":"支持的访问类型：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b29ab001dc182a2b65734a98a9","topic":"顺序访问","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"a6384cbf-47d9-48a7-9cf9-a81c82b76eca","topic":"不能直接访问","expanded":true}]}]},{"id":"7dd9ba1484a91f2d30e838bfbb","topic":"隐式链接","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"e767bc1c-82a2-4875-a468-b613275b3730","topic":"在每一个盘块的末尾都存有一个【指向下一个盘块】的指针","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ea4c36c3d6f358.png","width":394.56,"height":324.27}},{"id":"bb09a3be34fb065fe1df88908d","topic":"目录表：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"ca8a47dbe7392d57b465bae554","topic":"<文件名、起始盘块号、末尾盘块号>","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"bbf87bbb77cb8cb63f91b82b01","topic":"缺点：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"52e848e5fefa3f82a75549885e","topic":"稳定性不够，容易丢失数据","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"f9db006919f853f4540b28cb2a","topic":"指针会消耗空间","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"5c6b54421f682bb7d243f9e9f1","topic":"只能顺序访问，有大量的IO，很费事","expanded":true,"style":{"background":"#FDD834"}}]}]},{"id":"7e1b392ccc1a59a7808feb73da","topic":"显式链接","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"14dabe9b-3086-4d69-92d9-a0c59ac19236","topic":"FAT表","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c8a41cb5a8b9e4.png","width":282.4,"height":245.55}},{"id":"4a6bac14ac5b00aeb20429875e","topic":"目录表：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"6d2bb5024d58ae6116e2eb8c2f","topic":"文件名、起始盘块号","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"9bd81d7cdedb0004fcba79c40e","topic":"文件分配表：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"b80a1e2391b8394bb2d0cb4060","topic":"英文：","expanded":true,"children":[{"id":"09eaae4e55984554ae353801dd","topic":"FAT","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"032a85da66fa69884e234a5a14","topic":"内容：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c4abffe27f181d10afc948c3b3","topic":"下一块的号码","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"775230d1-18e9-45be-b7c1-bfd6811c9a18","topic":"不存有盘块号","expanded":true}]},{"id":"502989fb96598c3d18f9c88780","topic":"如果是最后一块就是-1，如果没有被分配就是-2","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"936983e9965a8e24ec43caa09f","topic":"FAT在启动时：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"ca09440270cbe14dc4c09abeec","topic":"和文件目录表一样，刚启动就被导入内存，所以很明显的提高了检索速度","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"ce4ac6c929d8c84a83f978e193","topic":"缺点：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"dfe8e34c92c9f1cc92948ad0d1","topic":"每次启动的时候都要把FAT读入内存，若FAT很大，则会占用大量的内存","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"da1ba780-db5d-4fd7-acc6-8bea0976f4e1","topic":"身兼数职，还可以负责管理磁盘的空闲空间","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"d3b253e5-57c0-43c0-a426-0e7b1c56c7cd","topic":"磁盘章节，-2就是空闲盘块","expanded":true}]}]}]},{"id":"136b3d008cb8e5450eda4bc1b8","topic":"索引分配","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"d4521541-3b46-4d75-bf97-07cb7c2b64f1","topic":"图示","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c8905a1b253d53.png","width":414.18,"height":315.03}},{"id":"8d8a187e0b6adad00d39e9e4ee","topic":"原理：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e449b7b310c88461208ceb68b9","topic":"【每个文件对应有一个索引表】，内存中的文件目录表存的是每个文件对应的索引表块号，当要访问一个文件的时候，首先把该文件【的索引表从外存读入内存】","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"83593001b109905defe378a50f","topic":"目录表：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"260aa81f630b1b7f397b58bb97","topic":"<文件名、索引表块号>","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"646a112137bb8993ab8438605c","topic":"索引表：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"458befbeabba488b426069d6f3","topic":"顺序地存有文件的块号","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"613b320d50590088e9298969d7","topic":"优缺点：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"8b1b4348173a00d2c4e918b71f","topic":"优点：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c6b8cbf2c85b829a7082bb36f3","topic":"支持随机、顺序存取","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"65bac87d0f380f2d5f3cb887ef","topic":"文件拓展很方便","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"b80b7cd4d43b2523dd9cf9bb87","topic":"比起显示链接，不需要把索引表同时存入到内存中","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"8f3b06f72439a9edd922e83a31","topic":"缺点：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"c009f9207cc98ef89480f99a46","topic":"如果程序很大的话，一个块大小的索引表不够用","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"45c804641ae99db6c7ee9847c0","topic":"缺点优化：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"302b75632da8122955113aa4ec","topic":"链接方案：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"8ea9f9ccf0783d28571c3bc82e","topic":"如果一个块大小的索引表存不够，那么索引表最后就指向下一个索引表的块","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"3e0b65683f0a2b290092499599","topic":"多层索引：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"d228052463382150f8708b3d7d","topic":"和多级页表一样，首先访问一级索引表，然后再访问二级索引表","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"71ce4d34-39fd-4c53-9af8-d3a2c498bd1f","topic":"混合索引","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"029b0d602ad8c5a6a398cb96b8","topic":"混合索引：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"a52b7743e4a9791c4728da9d9d","topic":"图示","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-055344d652400c.png","width":366.83,"height":332.94},"children":[{"id":"17bb7a9d-fae5-40f1-97cc-878b9ec6d0fc","topic":"一个索引表中，存在","expanded":true},{"id":"d2abd519-157b-4142-a825-b81d9f245da9","topic":"1. 直接地址（直接指向一个块）","expanded":true,"children":[{"id":"d463a35e-7fff-4981-814b-58344827a8ed","topic":"i.addr(0) ~ i.addr(9)","expanded":true}]},{"id":"2000024b-327c-4e05-8843-157aaf1f5065","topic":"2. 一级间接（指向一个索引表）","expanded":true,"children":[{"id":"b23200ef-c58a-4a5b-9936-c5b402ddb134","topic":"i.addr(10)","expanded":true}]},{"id":"ae299f52-6ddd-4a7c-80a2-ebe83cee144a","topic":"3. 二级间接（指向一个二级索引表）","expanded":true}]}]},{"id":"2a99aaf8-5049-4069-bd96-6680478c0675","topic":"如果访问一个文件中第n块中的记录：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"341a84d2-e6ec-4f8e-8c67-5245df871a2e","topic":"连续分配","expanded":true,"children":[{"id":"154728e3-e819-468e-9446-15e9b7c907a7","topic":"只需访问一次磁盘","expanded":true}]},{"id":"c02589b5-923f-4182-aef3-0a15f584f604","topic":"链接分配","expanded":true,"children":[{"id":"6ebdd704-1ccc-44cb-877c-600806291876","topic":"隐性","expanded":true,"children":[{"id":"e8c9505f-da56-432c-9c49-d418fe1c7b1f","topic":"需要访问n次磁盘","expanded":true}]},{"id":"6ccafdad-bdda-4f79-99d2-9b346a67a863","topic":"显性","expanded":true,"children":[{"id":"d4d4025b-23ac-4281-a049-e15b2dc2a9e1","topic":"需要访问1次磁盘","expanded":true}]}]},{"id":"3c9afcbe-08d7-4409-91d7-93cf4c1607e9","topic":"索引分配","expanded":true,"children":[{"id":"ad55e83b-3aa7-43a0-ab97-9facfa2497f1","topic":"访问两次磁盘（一次读索引表，一次读文件）","expanded":true},{"id":"6096bcc5-96ad-44c0-be4c-d10ca58e13bc","topic":"可能存在超过两次访问（如果索引表一块磁盘装不下）","expanded":true}]}]}]},{"id":"2168e6428a88cbd579585a5a12","topic":"文件的目录结构","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1b2d365e674989.svg"},"children":[{"id":"17d4eebc-5c5d-4431-ac89-63625b40acf6","topic":"文件目录项","expanded":true,"children":[{"id":"dd5a67c15b9ac14d4b93bb6631","topic":"文件控制块","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"52f93b1cb4197da38a36e98137","topic":"缩写","expanded":true,"children":[{"id":"65799890dfe8190be7cdc9a7e3","topic":"FCB","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"a1a9576df3ebe74cbffc2b3e3f","topic":"存储方式","expanded":true,"children":[{"id":"512a56497729ced4ec3289788c","topic":"顺序存储、顺序文件","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"15ba2d2e8fe8802b1f266ae345","topic":"包含信息","expanded":true,"children":[{"id":"ed3b5a65c32b003e266cf9c7d8","topic":"基本信息","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"6758241231f81a6089dcdbf778","topic":"文件名、物理位置、逻辑结构、物理结构","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"4b693550c71902660651f9efa0","topic":"存取信息","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"7698c3862f683fe5d38d2837ab","topic":"存取权限","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"e1f835c500a9ffa86a1af91f73","topic":"使用信息","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"16ba5c42e07bbfc0084d98aff2","topic":"建立时间、修改时间","expanded":true,"style":{"background":"#8EDDF9"}}]}]}]},{"id":"6afac0aad77a0b61a6bee9bf19","topic":"索引节点","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c10986a5d17bf1285ec80ab0fd","topic":"作用","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"2415e2c8-8ee5-4506-8b8b-6e374eb63054","topic":"用来“瘦身”","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"b2719708-3cbb-4524-ad45-1ef3cc7c4c10","topic":"存放在内存中","expanded":true},{"id":"c1d24a4b-c0a4-4501-b074-d875f4b73c36","topic":"FCB = <文件名> + <索引节点>","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"bd6acc6ffd39c0d226933aa394","topic":"因为在查找的时候只有对应文件名的目录项才有用处，所以没必要把所有FCB都读进来，用一个索引节点（指针）来代替FCB的包含信息就可以了","expanded":true}]},{"id":"b08ab1081bcb7b5fbacdbaae58","topic":"磁盘索引节点","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"771915ba84996b5b790acbfd1d","topic":"存放位置：","expanded":true,"children":[{"id":"04088efd104822ddaca7d8113d","topic":"外存中","expanded":true}]},{"id":"4baada49156bb9b36a76eb166d","topic":"每个文件的磁盘索引节点唯一","expanded":true},{"id":"7058ed80b96a949080ec986ce6","topic":"包括的内容","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"6539b6a23e8b023e256dfadc40","topic":"主标识符","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"fc6b6d3d8d5b1ae94752fb707e","topic":"拥有该文件的个人/小组标识符","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"8fe8fde28a2a8b6498ce1a1272","topic":"类型","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"f58c70e5-8f93-4e4d-91f3-a302ce8caf55","topic":"普通文件/目录文件/特别文件","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"9b2bd78fbfcacc0c93134bd87a","topic":"存取权限","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"821bb8e5-0d31-41e2-b067-867d41b9d07b","topic":"各类用户对文件的权限","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"8a48cc5be72adf989cafea2c00","topic":"物理地址","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"f158ca057e5b4e6e9a1c480b05","topic":"每个索引节点有13个地址项， iaddr(0) ~ iaddr(12)， 可以直接或间接给出数据所在盘块编号","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"c11127bd-7edf-44ed-be2f-7bf53d112e26","topic":"0~9 直接地址","expanded":true},{"id":"12e9d195-fc5e-4230-ab21-de7c2386a67a","topic":"10 一级页表","expanded":true},{"id":"48859fbd-675e-4573-8d02-586bd7cc3aa2","topic":"11 二级页表","expanded":true},{"id":"4b8904c4-24f9-4d4f-86a4-7cfc71175e2d","topic":"12 三级页表","expanded":true}]}]},{"id":"e809228e82bac9aad23ab80a2c","topic":"文件长度","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"9092a27e-aa09-4277-b05b-725d22de53ab","topic":"✅","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"ca895883c6eae4e08dc2e92e87","topic":"文件链接数","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"0f4b62b3160a477b12b5a8a048","topic":"所有指向该文件的指针数","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"1f7ad96232fa04297cdceacb0f","topic":"文件存取时间","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"a032d97c-6cf0-4eb9-b5bd-0bcb0a5f8204","topic":"✅","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"45dab584adfad0e61608a9743e","topic":"文件调入内存","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"36b1902f-abf5-4136-9a21-a51cafe033bf","topic":"文件调入前：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"4313262d-ebbb-48c5-84d6-250ef1dccc7e","topic":"文件调入内存以前仅存放在磁盘中，调入内存后，复制磁盘索引节点，增加以下内容，形成了(内存)索引节点","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"733dd873-6783-4351-83d1-771683266baf","topic":"索引节点增加的内容：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"507b619fb5d9684641409938cb","topic":"索引节点编号","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"d651169d-b2a0-4a12-a316-08786ac2783d","topic":"用于标识内存的索引节点","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"5dba684f922bbb599f73682652","topic":"状态","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"da18be6391fbd9cbbe157adcb1","topic":"是否上锁/被修改","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"456b69e7333bdb7fd463b9e956","topic":"访问计数","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"8006e5dd-9a23-4a3a-8ff1-ec625ee8a801","topic":"有多少进程现在正在访问","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"833b101635b8724c3fbc7a115f","topic":"逻辑设备号","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"937b94183e09fb3aa190391a24","topic":"文件所属文件系统的逻辑设备号","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"dc4aede961790a2ba0c28a11fe","topic":"链接指针","expanded":true,"style":{"background":"#D0D0D0"},"children":[{"id":"d9d9783ad69980a988e96b9721","topic":"指向空闲链表和散列队列的指针","expanded":true,"style":{"background":"#D0D0D0"}}]}]}]},{"id":"42849f69-05a0-4aab-8573-b5c3e9ee2c66","topic":"主类存物文文文，号状访计逻设针","expanded":true,"style":{"background":"#FDD834","shape":"rect"}}]},{"id":"1e8762a1-c519-4331-b18e-932af4ea3e61","topic":"索引节点 = 磁盘索引节点 + 附加内容","expanded":true,"style":{"background":"#0CE6CF","shape":"rect"}}]}]},{"id":"21899d241b585e081948e87623","topic":"目录结构","expanded":true,"children":[{"id":"c60a35abd5299d1dcf8bc87459","topic":"（搜索、创建文件、删除文件、显示目录、修改目录）对目录结构的影响","expanded":true,"children":[{"id":"032bc6d9a8489fb111045a14a5","topic":"搜索文件时，要【查找目录】","expanded":true},{"id":"89896362171b5d99eca059249f","topic":"创建文件时【创建】对应目录项","expanded":true},{"id":"1f0a7e1761e92949b31c69600a","topic":"删除文件时【删除】对应目录项","expanded":true},{"id":"df5a953b85b93884fef03aaa3d","topic":"【显示当前界面中所有的目录项的内容】，包括文件属性...","expanded":true},{"id":"713b7c75537be0e7034e99cc20","topic":"修改文件的同时也要【修改相应的目录】","expanded":true}]},{"id":"30fa23fde37856ee4a57db7bf1","topic":"四种目录结构","expanded":true,"children":[{"id":"d90bf86aa7fbd448a226784c22","topic":"单/一级目录结构","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"e88ada3ab599db13dccb183c24","topic":"示意图：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"b73209f6-8d1c-4c7d-b1b4-02e0ab1b7e68","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8dc3c6f9a608b8.png","width":232,"height":64}}]},{"id":"d48836727dc822c0e7791ac36a","topic":"缺点：","expanded":true,"children":[{"id":"60194c059e78ad3c9ea4bb2979","topic":"不允许重名","expanded":true},{"id":"606b2045f94bdc3705132b0799","topic":"不适用于多用户","expanded":true}]}]},{"id":"2b9afd5b3d78b1d37ec5abdc7a","topic":"两级目录结构","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"31787df7b158ce162a8c884a57","topic":"示意图：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"9579cb02d3db4e9775832a8ef6","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-2135f23d4e64f3.png","width":352.51,"height":116.52}},{"id":"f28a01045bb804a4f0c6bab36a","topic":"分为主文件目录、用户文件目录","expanded":true}]},{"id":"a07a025aae98834d7c9c8804b5","topic":"缺点：","expanded":true,"children":[{"id":"c1aa9acbbea836c6df3118b5e9","topic":"缺乏灵活性","expanded":true},{"id":"10b9c58b8e68ea4b10eaca804d","topic":"不能共享文件","expanded":true},{"id":"7a69883aa48b801e1d657b6ab4","topic":"不能对文件分类","expanded":true}]}]},{"id":"1488abe1866b1a506dfe2a1ba5","topic":"多级/树形目录结构","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"563a4338625ac27a2da0098b6e","topic":"示意图：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"4596dd27-e7db-4555-9c88-db901dff9da3","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-17d564c9a15415.png","width":379.54,"height":174.11}}]},{"id":"bd1927e14ccb07c437d1c969ab","topic":"树形目录结构，现代OS都在用","expanded":true},{"id":"be69feec48f976731e7f792920","topic":"绝对路径、相对路径：","expanded":true,"children":[{"id":"167eb084-a37b-4a70-9cd6-5826d9604f3b","topic":"绝对路径就是从根出发的整个目录结构","expanded":true},{"id":"a84c8d37-21c7-45f6-bf8b-bc3d873a55f5","topic":"相对路径就是从当前文件夹出发的整个目录结构","expanded":true}]},{"id":"462988142c696201cacdfab8fb","topic":"缺点","expanded":true,"children":[{"id":"d94af505c74850788650483920","topic":"不能共享文件","expanded":true},{"id":"7028767ff428c2088d67e8995d","topic":"搜索路径长，增加了磁盘访问次数","expanded":true}]}]},{"id":"426b4a91a55a435bc3a7293402","topic":"无环图目录结构","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"f65a30e6c81a90df4e174a49df","topic":"示意图：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a6fdc83f-a1be-49ec-8b7c-1c094b760e5c","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ef8b6c739205ae.png","width":387.26,"height":299.96},"children":[{"id":"c34d5900-e166-4d52-b12e-fb68fceb5065","topic":"DAG图","expanded":true}]}]},{"id":"e7f88370d8cb118457b4eb4e58","topic":"共享计数器：","expanded":true,"children":[{"id":"82ea5b19f1680afcb9707beab0","topic":"每有一个进程访问该文件，计数器就++","expanded":true},{"id":"bc6af30761b8deaa6e7e8b5be0","topic":"少一个就--","expanded":true},{"id":"c8a9ce9009684c98f002983e54","topic":"=0，就退出内存","expanded":true}]}]}]}]},{"id":"1279ecc5-bf19-4cde-9dda-13b91abb27ec","topic":"目录操作","expanded":true,"children":[{"id":"7785991b-41a4-48b7-984b-f2f150daa201","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-d3cf162d462d03.png","width":644,"height":251},"children":[{"id":"07d7b9b9-0a74-47cc-b64a-ddc60af83838","topic":"create","expanded":true,"children":[{"id":"6b606ecc-d1db-41da-a897-f29fd4e1f275","topic":"指明新建文件A属于哪个path(父目录B是谁)。创建后B的目录会新建一个指向A的FCB","expanded":true},{"id":"74b34e57-0d17-478e-9303-c6f6bd2d55be","topic":"create创建的初始目录中包含有. 和 .. 两个文件","expanded":true,"children":[{"id":"6b3bbdaf-3f7f-4568-bf6c-1980fcf4314c","topic":"cd ./child_file","expanded":true,"children":[{"id":"7eaa768b-c50f-49bd-98bf-6ad877274cf6","topic":". 即本文件目录","expanded":true}]},{"id":"d1faf2fa-7f89-4149-9199-327d193641b3","topic":"cd ../father_file2","expanded":true,"children":[{"id":"2014b0a1-41ef-4d26-bf0f-f2f4270a82ac","topic":".. 即父文件目录","expanded":true}]}]}]},{"id":"afaf51fa-bb25-4e37-8415-be18b953c219","topic":"delete","expanded":true,"children":[{"id":"b2872c37-95df-4c0a-af80-7de66ab635b7","topic":"删除FCB、回收空间；如果删除非空目录，则其中所有的文件都要被删除","expanded":true}]},{"id":"86394188-d0f6-419c-a4c9-7f1bfb935869","topic":"opendir","expanded":true,"children":[{"id":"e31d291f-f823-4878-9844-cc8e5945ac79","topic":"把目录的所有FCB读入到内存中","expanded":true}]},{"id":"83eca921-0090-4d63-aa25-f1c1c827bcf2","topic":"readdir","expanded":true,"children":[{"id":"e44a3e3c-ee58-4ece-a117-742bd17a3b11","topic":"从opendir中的FCB中找文件的对应fd","expanded":true}]},{"id":"9af7f076-32b4-4aec-93ec-d2c54b35b025","topic":"rename","expanded":true,"children":[{"id":"dab74a45-3e51-492a-ace2-042a5d0fc38c","topic":"本质是修改指向这个目录文件的FCB中的名字","expanded":true}]},{"id":"72d2daba-e769-46f5-963a-c5e585163711","topic":"link","expanded":true,"children":[{"id":"fe9cb737-be73-461a-af93-4f8404acc6d8","topic":"硬链接","expanded":true}]},{"id":"67aab475-ee93-4b47-a631-e5cba0e22852","topic":"unlink","expanded":true,"children":[{"id":"309e5e6e-9075-4bda-b483-b51300e7e774","topic":"解除硬链接","expanded":true}]}]}]},{"id":"5ce666c6-884a-4937-8aad-9f7b09179397","topic":"目录的物理实现：","expanded":true,"children":[{"id":"4936fd4f-788e-4b8e-99d5-12b8db4a84b0","topic":"线性列表","expanded":true,"children":[{"id":"1f693125-94b7-44c7-90b5-cc38bd995e3f","topic":"对应线性查找","expanded":true}]},{"id":"a568fc04-3508-49e8-ba75-fc94c0bc51dd","topic":"哈希表","expanded":true,"children":[{"id":"3d5de4b6-a6ea-4296-b9b9-ea7c9056fbb5","topic":"采用哈希函数来快速定位文件","expanded":true}]}]},{"id":"b2b973eb22996f42fe6788fc61","topic":"共享","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"0c1867481fd82e1daf23482af2","topic":"硬链接","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"eeab40fae958b5da67e1cad6c3","topic":"文件指向同一个inode","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-5b7e90bdeddb0f.png","width":472.72,"height":255.61},"children":[{"id":"98e82717-3ba7-4dee-a502-b61f615faea4","topic":"索引节点的两大功能","expanded":true,"children":[{"id":"be2b69d0a93ab928db8f597ddb","topic":"文件链接数","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"0f89ede592f8a00fe7ceb9d364","topic":"在采用索引节点存储方式的OS中，文件目录可以指向同一个索引节点，文件链接数就保存这个值","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"e85b458dff39de929754fbd2fd","topic":"链接数!=0，不能删除文件","expanded":true}]},{"id":"067b4ed7fb58410475d31bc967","topic":"访问计数","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a31a23fead884756c8667b678d","topic":"在内存中运行时的访问计数","expanded":true,"style":{"background":"#8EDDF9"}}]}]}]}]},{"id":"5e5ab36d7ea85dd76417ea88cf","topic":"软链接","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"e69ec81c-691c-46e4-8e3f-acf76e1939d9","topic":"使用符号链，创建一个LINK类新文件","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c6fc8d9eea3521.png","width":470.56,"height":256.92},"children":[{"id":"bd2a76a94e6a1ddc237658f689","topic":"新文件：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"9f1a718b2108018df0b6991d40","topic":"创建一个LINK类型的新文件","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"e12bf991cba879dc8cd4b8225b","topic":"LINK中只存储符号链","expanded":true}]},{"id":"95cb25f0897b9dca123f295245","topic":"软链接特点：","expanded":true,"children":[{"id":"838814afd879c8155400cae381","topic":"软链接文件只存储路径","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"10f94bd666591b7d89a9698035","topic":"不知道文件是否被删除","expanded":true,"children":[{"id":"0a19c4c2a8fb470f0eb12bcb6d","topic":"一访问就知道","expanded":true,"style":{"background":"#8EDDF9"}}]}]}]}]}]},{"id":"1c3d11a1-9a5c-40f1-800b-279dca74c0e1","topic":"文件的目录结构是文件的目录的结构信息，例如：单极、多级目录","expanded":true,"style":{"background":"#EEEEEE","shape":"rounded"}},{"id":"856b1b2e-3389-4044-b4b1-015f862bd112","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"810b0361-febf-46da-9961-5f02a68b52fb","topic":"09、10、17、20、21","expanded":true}]}]},{"id":"48f81ec8b129956e67a049ab7f","topic":"文件系统","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-10b98166f49f62.svg"},"children":[{"id":"bafbb40a-ac67-49d0-abcb-139c7b2be2ba","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"714c4a0f-0f48-42db-bb8c-597b43829ef7","topic":"15、19","expanded":true}]},{"id":"79ff80dd-6908-437b-a7fb-d1f5870019a1","topic":"OS管理外存的空闲盘块、分区、VFS等","expanded":true,"style":{"background":"#EEEEEE","shape":"rounded"}},{"id":"61a5f04e-e9fc-4308-9d09-ec125b0f528d","topic":"文件系统结构：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"40c0ce6d-6f1c-45d5-9f76-7689609f545d","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-d403586e813ea1.png","width":182.73,"height":430.96},"children":[{"id":"75fd71f9-5a85-4721-8c2f-07f0fff3e3c0","topic":"4. 逻辑文件系统","expanded":true,"children":[{"id":"daced21e-b3fe-4b2d-b48b-3f367799f86f","topic":"管理元数据信息","expanded":true,"style":{"background":"#FF9595"}},{"id":"68ba4f0c-0686-4978-ad12-831f8a9b9900","topic":"包括文件所有结构，不包括实际数据（文件内容）","expanded":true},{"id":"bc627ed2-68bc-4cbb-8553-be94c0e037cd","topic":"管理目录结构，通过文件控制块维护文件结构、文件保护","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"9812002c-e2d4-4ace-805f-c0065c42cbfe","topic":"3. 文件组织模块","expanded":true,"children":[{"id":"33201b38-ae12-4bce-9038-1540e398183b","topic":"组织文件、文件的逻辑块和物理块","expanded":true},{"id":"aae24214-3829-4108-8e8d-cef71a6b8e16","topic":"可以把逻辑地址转为物理地址","expanded":true,"style":{"background":"#FF9595"}},{"id":"f851e0bb-5eb8-4aa4-9654-a9ba951726f1","topic":"包括空闲空间管理器，跟踪没有被分配的块","expanded":true}]},{"id":"bbf222f5-c348-4ae3-a232-beae4a8de22f","topic":"2. 基本文件系统","expanded":true,"children":[{"id":"9bbe110c-5308-426f-9953-6208c2b5aed7","topic":"向对应的设备驱动程序发送通用命令，以读取和写入磁盘的物理块。","expanded":true,"style":{"background":"#FF9595"}},{"id":"9f71289e-1039-4edb-9bf6-fa09cec012fc","topic":"管理内存缓冲区，保存各种文件系统、目录、数据块缓存。","expanded":true}]},{"id":"67b39af8-cc0c-453c-a9ac-21ed84c8ebfa","topic":"1. I/O控制","expanded":true,"children":[{"id":"230a54d9-13e4-48b1-867f-f57c8d8518dd","topic":"包括设备驱动程序和中断处理程序，在内存和磁盘系统之间传输信息","expanded":true},{"id":"fad1dc10-8876-4e25-9514-535934a09f41","topic":"将输入命令翻译成硬件指令","expanded":true,"style":{"background":"#FF9595"}}]}]}]},{"id":"8639d75c20ca061dd161498d0a","topic":"划分和初始化","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"4d4a0293a8aa2be2a9dbca9e1b","topic":"划分：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"06d8585e032b3b7203755b6da8","topic":"超大型文件卷可以有多个物理盘","expanded":true,"style":{"background":"#8EDE99"}},{"id":"68e85063ead970e53869193465","topic":"一个物理盘可以分为多个卷","expanded":true,"style":{"background":"#8EDE99"}},{"id":"e9ea0693390abf29f8fc29823c","topic":"每个卷可以分为目录区+文件区","expanded":true,"children":[{"id":"9fcaa651be8b0d69b0792bf2e2","topic":"目录区：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"644a972bda1993733c86786c59","topic":"存放FCB（文件控制块）","expanded":true,"style":{"background":"#8EDE99"}},{"id":"468807509fca0ac7da46e8e3fb","topic":"磁盘存储空间管理的信息","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"f5751945-e195-4720-b6c2-da76a25cbc0b","topic":"文件区：","expanded":true,"children":[{"id":"722db0c9-0ad8-487d-a42c-e274be15beab","topic":"存储文件数据","expanded":true}]}]}]}]},{"id":"95faec7ec6a9cf288a50d933cf","topic":"外存空闲空间管理","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"331b78e9594a7b0843a8688d91","topic":"空闲表法","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c2aa08e3264a20660ff5397367","topic":"分配方式：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"3e79f8fa6f7a767037bb5b6715","topic":"连续分配","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"70650e2a-e78c-49d3-a928-c71642528f67","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-5b4e45826cea4b.png","width":427.43,"height":300.15}}]}]},{"id":"11882f4c352bfbc00699c8b521","topic":"空闲盘块表：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"aaba83fea12a894df0a50beb31","topic":"<空闲盘块号、空闲盘块数>","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"6069104764b92b9915c139633e","topic":"分配算法：","expanded":true,"children":[{"id":"b8ab8fe20058583df229fb939b","topic":"最佳、首次、最坏、临近","expanded":true}]},{"id":"94f93926462b5d7c991f5b6e93","topic":"存储回收：","expanded":true,"children":[{"id":"f9c94e5fc43a8eb459c5696c62","topic":"和动态分区分配内存回收算法一致","expanded":true}]}]},{"id":"c7281863eb99fd97abcc984eaa","topic":"空闲链表法","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a5ec21e9-1818-4494-ae76-aadd3d81f9c6","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-68c89344333ad8.png","width":549.1,"height":352.97}},{"id":"0afab93b41a9f7b6d22b5a3525","topic":"空闲盘块链：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"01e9245b8d19c38c6d12190209","topic":"分配模式：","expanded":true,"children":[{"id":"e1d92efd0828a9691f1f4bc789","topic":"离散分配","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"95aa07d1524aa85fafda98afba","topic":"数据结构：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"2a08a3c79f0835bfc3533ac716","topic":"每一个盘块都有指针、一个链头、一个链尾","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"8cb91025fc7b9bf7e514b807bd","topic":"分配算法：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"8379e0029b8b21a41eadd8b290","topic":"从链头拿k个块，分配给进程","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"edcb5d18ac4b2125387dc93e73","topic":"回收算法：","expanded":true,"children":[{"id":"ddf9f94fbe985dc8a1354af2df","topic":"把回收的盘块，放到链尾","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"7979a15a41dae38a8287e89cdd","topic":"空闲盘区链：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"6148e7a3108b51dc6ee7299783","topic":"分配模式：","expanded":true,"children":[{"id":"4d7a04b713a9833c22f14b0888","topic":"离散分配+连续分配","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"802ae3dd0c5b3f2cb2f4aa6ceb","topic":"数据结构：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"7979b81095b85332d3098a1ff6","topic":"每一个盘区由相邻的盘块组成，每个盘区有一个链头、一个链尾、本盘区大小","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"448937e3e46b052293de1990a0","topic":"分配算法：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c63a64b580894eb7d37b2be86d","topic":"和内存的动态分区分配一样，通常采用首次适应算法","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"32ea9ec15a78bdd0802ecb5c25","topic":"回收算法：","expanded":true,"children":[{"id":"37085d0c342a01f5c8f189731d","topic":"将回收区和相邻的空闲盘区合并","expanded":true,"style":{"background":"#8EDDF9"}}]}]}]},{"id":"581811d257b9c918458d890c91","topic":"位示图法","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"7b7a413ea49b0420fd4259ec0b","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-5443b20439e4df.png","width":475.21,"height":149.73},"children":[{"id":"b13ab2f762287aa130a0c9a78b","topic":"字号、位号和盘块号进行转化","expanded":true}]},{"id":"df89f55b5eabfe30f4e06b7a03","topic":"分配算法：","expanded":true,"children":[{"id":"08272592-88b3-4cba-bbe2-5ea78e62b212","topic":"如何分配：","expanded":true,"children":[{"id":"0200f983-a7d0-45ae-99f2-169d49ee13b8","topic":"需要M个，就顺序扫描位示图，找到M个0就行（无所谓连续与否）","expanded":true}]},{"id":"fe0b150639aac224df83a980dd","topic":"如何找k个连续的","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"f45928c4f59b4426d42eb87f81","topic":"在二进制数组中找到k个相邻的空闲块（k个连续0）","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"129873c6e22b6874ca970b391d","topic":"然后把这个k个二进制位改为1","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"3d99f23beed86be2548ec90d46","topic":"回收算法：","expanded":true,"children":[{"id":"48db75bad81acef4e38648867d","topic":"首先获得盘块号，然后推出位示图的行号和列号","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"e2ab5266c84ac166e1eb58c090","topic":"修改位示图，把对应的二进制位改为0","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"e659fcbd5658183afc00e9329a","topic":"成组链接法","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"f5fb3cccdf0b5ab15d3cbb9efe","topic":"上述算法的缺点：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"a758fbd16d0b6ebef53709637c","topic":"无法适用于大型文件系统，因为会导致空闲表和空闲链表太大","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"624dbc68-b190-45c9-9eac-f032fbca2c00","topic":"超级块","expanded":true,"children":[{"id":"4ca81311-188d-4949-a5e6-9b4feddcb2d9","topic":"成组链接法的第一块","expanded":true}]},{"id":"07bbb0e2d408b51d32db9b52a9","topic":"图示：","expanded":true,"children":[{"id":"ee047864-fb3a-4149-a32f-860a7e9538d2","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-eb6a4df2d8155e.png","width":560.52,"height":327.86},"children":[{"id":"42566cf7-440a-46fb-b9af-0eb6c7eaa7f1","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-7e5ebec55d76dd.png","width":665.27,"height":332.89}}]}]},{"id":"bb5ad06c47b8b01e3d33991ee8","topic":"分配算法：","expanded":true,"children":[{"id":"e69a1ce8e7fb7e057033895ea8","topic":"需要小于当前空闲块号：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"4f4b01f080f8099fd46d0b4a6f","topic":"分配块出去，修改超级块的 1. 空闲块数 2. 空闲块号信息","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"804aead8c87a774fc9341b85a4","topic":"需要超过当前空闲块号：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"b7e8d30dc398bd618faa9b3e76","topic":"把下一个分组的块号表复制到这个超级快中，分配出去当前所有的空闲块号，如果还不够继续复制+分配","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"3d2ad6803178aba0b218492dc4","topic":"回收算法：","expanded":true,"children":[{"id":"db78ed05e96a682e2cab08caa9","topic":"如果有位置就填入到超级块当中","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"5d8a20bf592b08156dd00a81db","topic":"如果位置满了，就新建一个“成组链块”，指向现在满的这个超级块","expanded":true,"style":{"background":"#8EDDF9"}}]}]}]},{"id":"54c9fdda-fa57-4abd-b490-b9d062ed8eef","topic":"虚拟文件系统","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"89078820-08da-4232-8ba9-6c096ad08809","topic":"虚拟文件系统采用了面向对象的思想，它抽象出一个通用的文件系统模型，定义了通用文件系统都支持的接口。新的文件系统只要支持并实现这些接口，即可安装和使用。","expanded":true,"style":{"background":"#8EDE99"}},{"id":"d8b118f3-0beb-4b5f-a214-9da13185dad0","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-04ca717b39cffc.png","width":418.89,"height":465.95},"children":[{"id":"dc67be4d-2571-4a02-99ba-8c8ea3a09305","topic":"① 向上给进程提供一个统一的read、open调用","expanded":true},{"id":"93fd0103-b519-4be5-92b0-b1117b49edca","topic":"② 向下规定所有文件系统提供统一的打开、读、写、格式化等操作","expanded":true},{"id":"e7d35491-adca-4fcf-8309-07c40e013d31","topic":"③ VFS维护自己的在内存中的vnode，来表示文件，无论文件存储在哪一个文件系统中","expanded":true},{"id":"a4ff8c69-8258-49c5-82c0-90f3a814bb33","topic":"write()","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c147c9af-a5fa-4402-9782-278f3cd46da1","topic":"sys_write()","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"4e8c58f0-3903-4635-8c79-e83c3dec3492","topic":"文件系统的写方法","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"794bc9d6-c68d-49d2-8e25-0fcd18506572","topic":"物理介质","expanded":true,"style":{"background":"#8EDDF9"}}]}]}]}]},{"id":"898bcf32-78ec-4062-9b43-1cc718863b28","topic":"Linux抽象的四种对象类型","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"cee2a717-57a3-4ddb-8f9a-6414dbd3c540","topic":"图示","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-307d54fb24c872.png","width":350.64,"height":212.38},"children":[{"id":"aca7e9b0-cf71-4ee4-8dfe-213d7a054cf9","topic":"超级块对象","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e53b8711-30b7-490c-b6fe-80a8914cfb08","topic":"表示一个已安装（挂载）的特定文件系统","expanded":true,"style":{"background":"#FDD834"}},{"id":"5d9d0441-8b87-44af-bded-987ba17e02cf","topic":"对应磁盘中扇区的文件系统超级块，存储已安装文件系统的元信息","expanded":true,"style":{"background":"#FF9595"}},{"id":"6d9c034b-4ce0-435f-bb75-c478ccd0b407","topic":"有对超级块进行更改的操作函数，例如分配、销毁、读写inode等","expanded":true}]},{"id":"5c91c8d2-c0c9-4293-9eca-5ae3c127e38b","topic":"索引结点对象","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"7d848688-bb9e-42cc-a4b3-567539c305a5","topic":"表示一个特定的文件","expanded":true,"style":{"background":"#FDD834"}},{"id":"bb5d98be-a88c-447a-bdc0-14cfc5455dbf","topic":"文件系统处理文件所需要的所有信息，都放在里面，索引结点对文件是唯一的","expanded":true,"style":{"background":"#FF9595"}},{"id":"e88d3d4b-6a8b-41d9-8e7a-a731a07b540a","topic":"操作例如创建索引节点、硬链接、新目录等","expanded":true}]},{"id":"0dcfbe19-a459-4e77-92ac-88aec1d754eb","topic":"目录项对象","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"9d6ad5dd-5de3-4d11-9d90-ef8c205053d7","topic":"表示一个特定的进程","expanded":true,"style":{"background":"#FDD834"}},{"id":"25fbad3b-f142-42d6-b1d0-b71f65946a16","topic":"由于VFS经常执行切换到某个目录这种操作，为了提高效率，便引入了目录项的概念","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"337e6e27-f848-4f7a-a7da-7dadd5e530cc","topic":"文件对象","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e9841388-fb77-4dc1-bad1-30bd57379b64","topic":"表示一个与进程相关的已打开文件","expanded":true,"style":{"background":"#FDD834"}},{"id":"f07e2214-0ef6-4656-8689-ac473db2f0ad","topic":"文件对象代表进程打开的一个文件，open()调用打开，close()调用关闭","expanded":true,"style":{"background":"#FF9595"}}]}]}]}]},{"id":"325756c4-bc9f-4d52-bba7-9053c704f11a","topic":"分区、安装","expanded":true,"children":[{"id":"dc981c59-70bf-45be-b804-620b59d3d84c","topic":"分区：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a9a8006b-d46f-4f99-a347-566a140b8697","topic":"一个磁盘可以划分为多个分区，每个分区可以创建单独的文件系统，也可以有不同的操作系统","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"fc55afc9-d44e-4d94-9f2b-04e917fc4a4c","topic":"（例：装双系统）","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"facb3b7b-85e5-4330-b827-4ba7494b037b","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-9ac1315b9fbf39.png","width":442.29,"height":80.12}},{"id":"95586846-74df-41f7-b5ae-bb97ee0ba98e","topic":"引导块：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"6dbe11db-25fe-4034-8c88-0a33270f2196","topic":"存储引导信息，存储一系列连续的代码，可以启动一个具体操作系统的引导程序。","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"8ec2c8c5-6ef9-48a8-b39a-ed4418f5cc23","topic":"超级块：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"75691e51-a4d5-4476-b2e2-9c9bafd44a24","topic":"存储和文件系统有关信息，例如文件系统类型、i结点的个数、数据块个数等。","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"7f06bc10-9e42-4c27-967a-ff275baf26b6","topic":"i 结点：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"cd241f9d-792e-45c6-91ad-a28e8268ca5b","topic":"inode，有多个，每个文件对应一个","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"14167537-55e3-4f73-960c-433e80f3674d","topic":"数据块：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"6afc29e1-3f34-4f72-945c-a2758246b77d","topic":"存文件数据","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"4dfd9d26-6d8e-4c6c-b857-7d1949e1651f","topic":"安装：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"613af96e-e156-4279-8684-ed6fbdff8028","topic":"安装 ↔ 挂载","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"262ce5bf-dc3a-404a-a1c0-60f103965bfa","topic":"例如：插入U盘","expanded":true}]},{"id":"8d26a9bf-7e12-4247-a293-00c032f88917","topic":"WINDOWS/MAC自动发现设备，安装找到的文件系统","expanded":true,"style":{"background":"#8EDE99"}},{"id":"b6eb5a29-954c-43b8-a3b0-5c2e60281524","topic":"UNIX需要自行挂载文件系统：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"657b6475-fb36-42d1-852a-13e5f53b2ee0","topic":"mount -t ex2 /dev/fd0 /flp","expanded":true,"children":[{"id":"e3a9695b-969f-45c7-b148-eed2afe5ba3f","topic":"umount进行解除","expanded":true}]}]}]}]}]},{"id":"49812553-7ff1-4cd8-b5eb-3380e4a52cf4","topic":"两个补充","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-fb96c55c1fee10.svg"},"children":[{"id":"6022c600-8407-488a-ac36-b51fee04e646","topic":"UNIX文件系统","expanded":true,"children":[{"id":"59d6c6ef-1cbe-4960-b21c-21bd08fccd79","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-97b84e6cc7d2ed.png","width":1304.4,"height":485.06}}]},{"id":"d6e52b67-3033-48d5-a125-6173e73c3d27","topic":"全局结构Layout/\n文件在内存中的结构","expanded":true,"children":[{"id":"421a1c58-cbef-4d16-8fa0-ca6fe959d43f","topic":"概念：","expanded":true,"children":[{"id":"20dcf5a6-f5d6-429f-b04e-ea14c6ca2b9c","topic":"目录缓存：","expanded":true,"children":[{"id":"205db7db-e98a-4b40-bf8b-27b3524ba801","topic":"把最近读入过的目录文件的数据保存在内存中","expanded":true}]},{"id":"3f62917c-a250-4df2-87d8-f7fb3c9818a5","topic":"系统打开文件表：","expanded":true,"children":[{"id":"49356761-0072-4474-9a82-66c08528cc0f","topic":"保存一个系统中现在打开的文件，已经打开过多少次","expanded":true}]},{"id":"43b87b42-f910-4344-a8d9-37b5cf5eecd4","topic":"进程打开文件表：","expanded":true,"children":[{"id":"61090b7d-de69-43a3-b3ae-a4add909dddd","topic":"保存一个进程打开了哪些文件，记录在进程的PCB中","expanded":true}]}]},{"id":"94633749-93af-480d-8240-b2b0fc72a059","topic":"图示：","expanded":true,"children":[{"id":"0cb64898-44a4-4bd7-94ea-c0c3203f3967","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1bdbdddc6b2206.png","width":662.24,"height":366.11},"children":[{"id":"ff22b34b-1340-497f-82bb-55ad5145b436","topic":"① 使用open调用把文件目录调入内存","expanded":true},{"id":"4a7e8c08-7329-4611-8c2b-b6c19478d3c2","topic":"② 根据open中的文件名参数，在内存的目录缓存中找到对应的文件，记录其FCB等信息","expanded":true},{"id":"cbcb2654-f283-4e5b-9039-118706fefc58","topic":"③ 打开这个文件的进程同样需要把这个文件信息写入到自己的打开文件表中","expanded":true},{"id":"4b8c7365-422e-4b1d-96c4-1e61d6364ba8","topic":"如果用户要读一个文件","expanded":true,"children":[{"id":"7c727e8b-39f2-4eb2-853c-c9922bad6ea7","topic":"用户使用read(fd, xx, xx)来 1. 找进程打开文件表 2. 系统打开文件表 3. 访问外存","expanded":true}]}]}]}]}]},{"id":"838bd891-7575-47af-a0e5-ba50fd952959","topic":"END","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-e9c38dbbd7742f.svg"}}]},"relations":[{"id":"31b6ed12-dacd-44a5-8594-1cd6de32e397","from":"d8686039872b05bd29adab0024","to":"b7f9fa700cb86831eb33882eef","bidirectional":false}],"summaries":[{"id":"ab391aa1-1857-420a-a0f9-2e4b804254ae","parentId":"94e8d509e089866da21f9b1a2c","start":0,"end":1,"label":"因为索引表中含有表长，所以支持随机存储"},{"id":"39d28891-83bf-4ce6-a242-659526b9b4c3","parentId":"6f988cc392e89b2ecb0fd928c5","start":0,"end":1,"label":"搜索速度都很快，但是太浪费空间，一般不用"},{"id":"c61733f3-8ca3-44cc-a899-fb322eda0e88","parentId":"c10986a5d17bf1285ec80ab0fd","start":0,"end":1,"label":"故访问一次FCB需要访问两次内存"},{"id":"9a7d559e-9428-4f49-af25-079b2212c1a5","parentId":"8a48cc5be72adf989cafea2c00","start":0,"end":0,"label":"inode"},{"id":"1c42c330-d0a5-4ee0-b49f-c10513ff63d7","parentId":"733dd873-6783-4351-83d1-771683266baf","start":0,"end":3,"label":"用于管理文件的重要内容"},{"id":"4cd75cd7-fd76-495c-9c7c-6976d6264814","parentId":"be69feec48f976731e7f792920","start":1,"end":1,"label":"当前工作目录"},{"id":"4aac23af-66ea-41db-b582-f6de0e5ef9a2","parentId":"bafbb40a-ac67-49d0-abcb-139c7b2be2ba","start":0,"end":0,"label":"新考点"},{"id":"c41f7c93-7717-4b96-ae79-3262b491ae94","parentId":"4d4a0293a8aa2be2a9dbca9e1b","start":0,"end":1,"label":"就是Windows系统的CDE盘"},{"id":"c54344bd-0715-4e8b-a85e-0ac258fab4ac","parentId":"331b78e9594a7b0843a8688d91","start":2,"end":3,"label":"动态分区分配在内存管理的【连续分配】是高效的办法，比较低效是固定大小分区、直接分配"},{"id":"e1e27121-56a3-418e-b94c-46739329d909","parentId":"d8b118f3-0beb-4b5f-a214-9da13185dad0","start":0,"end":2,"label":""},{"id":"1820d2f0-f284-4bfe-928f-4c6d1b710f27","parentId":"48f81ec8b129956e67a049ab7f","start":2,"end":2,"label":"之前的图"},{"id":"2a5df80c-0e5d-49cd-88e8-9b5d9c5d2b1d","parentId":"0cb64898-44a4-4bd7-94ea-c0c3203f3967","start":1,"end":2,"label":"区别：【系统的打开文件表】记录的是文件在外存中的【地址】；而【进程的打开文件表】记录的是系统打开文件表的【索引号】"}],"boundaries":[{"id":"11ac6b5c-ef2d-45c8-9e50-e059d6c43c65","parentId":"53486bce-8600-486e-a753-c7ab415a2a4a","start":0,"end":1,"label":"物理结构"},{"id":"25cf60df-66d7-407a-b71c-41bbb9b346b0","parentId":"98e82717-3ba7-4dee-a502-b61f615faea4","start":1,"end":1,"label":"索引节点中"},{"id":"6b6c3ae2-834b-4941-9829-506da853a3fa","parentId":"98e82717-3ba7-4dee-a502-b61f615faea4","start":0,"end":0,"label":"磁盘索引节点中"},{"id":"2b6283e9-88bc-42d8-9783-ecacc5d4a69e","parentId":"d8b118f3-0beb-4b5f-a214-9da13185dad0","start":3,"end":3,"label":"Linux中调用write()的例子："}]}}},{"id":"be955543-2f9a-43ed-9d13-c58b612dec3c","topic":"I/O管理","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/operating-systems/os-00-sheet5","expanded":false,"maxHeight":260,"doc":{"format":"brushup-mindmap-v1","id":"os-00-sheet5","title":"I/O管理","structure":"timeline-h","theme":"auto","root":{"id":"7f2b43614e7932310d72fad486","topic":"I/O管理","expanded":true,"children":[{"id":"0d6a42a9b16ae27302131a70eb","topic":"I/O设备分类","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1fc7cca04627a2.svg"},"children":[{"id":"ba0a825f80f86ca8ac27db0a81","topic":"特性分类","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"17cb6344d7cba6078ab86aa180","topic":"人机交互类","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"3c270c74-7fbb-4b21-a9fb-cf99373c587c","topic":"如：打印机、显示器、键盘、鼠标","expanded":true},{"id":"13894973-505c-454a-8ff2-82b53053c016","topic":"交互速度较慢，一般是以字节为单位交换的","expanded":true}]},{"id":"9d484dc718abbba71f30380ee0","topic":"存储设备","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"cca6a799-b827-4f57-a714-5df4a3732085","topic":"如：磁盘、磁带、光盘","expanded":true},{"id":"c1ae1f75-0b73-4c39-b9be-c93402fc3e10","topic":"交互速度快，一般以多字节组成的一个块来进行交换的","expanded":true}]},{"id":"7e6a11a224582cf99e82f8c0f5","topic":"网络通信","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"06581685-2d7f-4e66-8932-cdc606b01ea8","topic":"如：网络接口、调制解调器","expanded":true},{"id":"97ae2f82-02ae-4358-a8c9-19035eb92469","topic":"速度居中","expanded":true}]}]},{"id":"d1caef215c68a745d52e6a6024","topic":"传输速率分类","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"28eb69ff2d8a896f3d7c7af57f","topic":"低速设备","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b1450c27-2d4c-4a01-9df1-ce40846088bf","topic":"几B到几百B/s","expanded":true},{"id":"3389c064-2a1c-4a45-985e-381e10fe054a","topic":"键盘、鼠标","expanded":true}]},{"id":"f33aed9db69919a32386c86c6f","topic":"中速","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"68132e4c-02c2-4706-af9d-49563641cbee","topic":"几千B到几万B/s","expanded":true},{"id":"901baca7-3b1d-48ac-b970-10bc3d20c00f","topic":"打印机","expanded":true}]},{"id":"8588d66a84a9136ab8036bb9a3","topic":"高速","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"f572b626-7907-4d98-92e0-e5fe1b08b668","topic":"兆B/s","expanded":true},{"id":"82aab58e-2488-4a52-9b98-16e722363aec","topic":"磁盘、U盘","expanded":true}]}]},{"id":"316a97a297ca81c3ac229b9517","topic":"信息交换分类","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"2769477717696bdbccd51aeb7a","topic":"块设备：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"61083c74645aecad944c7bc3f6","topic":"单位：","expanded":true,"children":[{"id":"f4689e353768bba15a23f9bbc1","topic":"以数据块为单位存取","expanded":true,"children":[{"id":"201db6c4-6d25-49bb-af1e-4a08659f7cb4","topic":"可寻址、支持随机存取","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"74d92a229279ccc6296b39b4b0","topic":"随机：","expanded":true,"children":[{"id":"7ccb544d191ab0e60e3cf865b3","topic":"可寻址，可随机存取","expanded":true}]},{"id":"b658ac96d08ac61b22432a718b","topic":"例如：","expanded":true,"children":[{"id":"80aae5193d1962dcc8b41ab9f9","topic":"磁盘","expanded":true}]}]},{"id":"9cfbb500656a2ee1617af9b266","topic":"字符设备：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"c2b92af95eda9eec8a924840d3","topic":"单位：","expanded":true,"children":[{"id":"85192c02b1799fcd4d051916de","topic":"字符","expanded":true,"children":[{"id":"f195afad-5eb8-4835-9394-461f180712f9","topic":"不可寻址、不可随机存取，使用中断驱动","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"dc5ab7b446ab04bb3d573a5934","topic":"随机：","expanded":true,"children":[{"id":"2dda8046135b771e28232bbe01","topic":"不可寻址","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"fb0a3682fe5933ab8a8499fd84","topic":"例如：","expanded":true,"children":[{"id":"891b88d33f0ac6a6c5df8a0265","topic":"打印机","expanded":true}]}]}]},{"id":"285a216d-2b53-4fcd-b617-463c45cea322","topic":"IO应用程序接口","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"a3114cb7-bfbb-4151-9517-57c3cf6a8569","topic":"字符设备接口","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"99a0766f-8df0-42f3-b13a-6fc7284007c7","topic":"例如：键盘、打印机","expanded":true},{"id":"2e3dc4ed-2901-4794-853c-6fd6dd2404da","topic":"输入输出：get、put指令","expanded":true,"children":[{"id":"37349513-be58-4199-aba9-8cddd2acd1b6","topic":"IO设备内部用一个字符缓冲区","expanded":true}]},{"id":"8642a4f9-4a5c-4eaa-b5a1-21f3e695aa28","topic":"控制：in-control指令","expanded":true}]},{"id":"87f8fd77-ca29-494a-955e-b8961fbc0db2","topic":"块设备接口","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"6274b3da-f765-4469-ab26-b9965b2392c9","topic":"交换数据块、例如：磁盘","expanded":true},{"id":"8063bcbe-b3ee-4eaf-bd4b-d1e7d6d4b9d7","topic":"通常使用DMA的IO方式","expanded":true}]},{"id":"648244e2-5a36-4580-acc4-f19b1071869b","topic":"网络接口","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"66afeccb-7a03-4aab-9686-503cfc584c1c","topic":"网络通信接口、例如socket","expanded":true}]},{"id":"6dd40feb-387e-4a96-8397-fe3321e5819e","topic":"阻塞IO","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"8b0b79b9-11b1-429e-8039-6785680c088d","topic":"阻塞IO是调用IO的时候，阻塞进程","expanded":true}]}]}]},{"id":"0b69a88cea299ca6e0384bc6fb","topic":"I/O控制器","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-bca4f4c7be28bf.svg"},"children":[{"id":"d7803490-2d67-470d-84f7-436eb38c5e12","topic":"I/O接口","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"06afd3e0-ccc4-4821-a343-9092f3089fa5","topic":"I/O控制器","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"68cf8728-f565-482a-8a58-757c1c271a29","topic":"设备控制器","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"dbaf8463-c2ab-4068-8d9a-fb8b3caab96d","topic":"I/O内部","expanded":true,"children":[{"id":"539ecc1a-69c2-4ed3-bd23-25e73bd90b76","topic":"机械部件","expanded":true,"children":[{"id":"8502dc1a-e09e-4075-a91a-7bcb976ddacb","topic":"看得见摸得着的实体","expanded":true}]},{"id":"74e36f2d-840e-49f4-81c8-9dc24ad68dab","topic":"电子部件","expanded":true,"children":[{"id":"0b2b380e-5082-43fc-bcaa-4f2d748ac643","topic":"藏起来的电路板","expanded":true}]}]},{"id":"454b6ce1cb0bc0b3edb79a75bc","topic":"I/O控制器组成","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"1a98e2211d291bd08175ca02c6","topic":"图示","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-b315506c02dc5b.png","width":686,"height":409.6},"children":[{"id":"cf224b2a-7eb7-428b-859b-f948987fc0ab","topic":"由图可知：","expanded":true},{"id":"c53b4f8e-e491-4bda-9523-a5d4de9513c6","topic":"1. 一个I/O控制器，管理多个IO设备","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"032258d7-f851-4300-947a-e1328b3f1991","topic":"一个I/O设备中，也可以连接多个I/O控制器（多通路IO系统）","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"301986af-1d87-49ef-b624-18bd694743f6","topic":"2. 每个I/O控制器中可以有多个(相同或不同的)寄存器。","expanded":true},{"id":"8d07e13c-7c77-44db-a7b9-edf38ca3bee2","topic":"3. 一个I/O控制器中有一个I/O逻辑，负责接受和识别CPU的命令，通过这个I/O逻辑，可以使这个I/O控制器管理的设备和CPU能够进行交互","expanded":true},{"id":"7508e12f-3834-498b-8291-930ec5cef618","topic":"4. I/O逻辑把命令发送到对应的接口处，由接口处的线来进行数据、控制的发送。同时也可以获得设备发来的状态","expanded":true,"children":[{"id":"c2e2701a-f9a4-4dff-be83-466d3e0084ba","topic":"这里的I/O逻辑到设备的接口模型和CPU到I/O控制器的模型基本一致","expanded":true,"style":{"background":"#8EDE99"}}]}]}]},{"id":"39c8835291ea798f7caf7bb817","topic":"I/O控制器功能","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"6413ca6f-3bed-472c-8b46-3af5272d37af","topic":"CPU无法直接控制I/O设备中的机器部件，所以I/O设备中还要有一个电子部件来作为中介","expanded":true},{"id":"450b2231516995ba3ae0d91e4f","topic":"又称：","expanded":true,"children":[{"id":"737a82c679aadeb064d61b7de7","topic":"设备控制器","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"4ebabf1166298a106fbeaac505","topic":"功能：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"426a34e02c986d127e5ce9ec71","topic":"接受和识别CPU命令","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"f14b17a32d89351cd95c9af63d","topic":"把CPU的命令：例如read/write，放到【控制寄存器】中，同时通过【控制线】告知I/O设备发送了命令","expanded":true}]},{"id":"9e788de5a589482d30aac821c4","topic":"向CPU报告设备状态","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"6459899d0a8939d1f185cb0457","topic":"【状态寄存器】，表示空闲忙碌","expanded":true}]},{"id":"fcf9829b6d8b5405f30f7a92b0","topic":"数据交换","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"8ddaaaba234a4db982945ab185","topic":"读写数据都放到【数据寄存器】","expanded":true}]},{"id":"f599b47a60f8f4e996b48a775c","topic":"地址识别","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"baa8f6bcc5d948a4739ecb5683","topic":"把逻辑IO寄存器地址翻译为物理地址，通过【地址线】进行传输","expanded":true}]}]}]},{"id":"4b48044e-7b90-4e97-b7ab-37d53260e7b6","topic":"I/O 端口","expanded":true,"children":[{"id":"e4ba7430-eddf-49fa-9619-8ad5e7e8c0bb","topic":"设备控制器中可被CPU直接访问的寄存器","expanded":true,"children":[{"id":"d6b780c0-e56b-4114-8b31-ca16d4da65af","topic":"上面白框","expanded":true}]},{"id":"802d6911-cfc5-4a58-88fd-e6718439f790","topic":"独立编址I/O","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-eee794b1609bd7.png","width":210.38,"height":182.21},"children":[{"id":"ddeadcab-978e-4e30-ad5b-b323516bdd5b","topic":"统一编址 = 内存映射I/O","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-50765270cd8a7d.png","width":145.64,"height":175.45},"children":[{"id":"0b5326dd-75df-4f1c-bd30-3e90103436fb","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8afe1875b1bf46.png","width":507.04,"height":273.91}}]}]},{"id":"f63841ae-7726-457f-9cdb-ea0930b61c0f","topic":"内存映射I/O简化了指令","expanded":true,"style":{"background":"#FF9595"}},{"id":"379738be-7639-4b3d-8f5f-74cbe86e95c2","topic":"寄存器独立编址让指令设计变得复杂，需要单独设计和read write相区别的指令(input output)","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"d869db0e88d99c188315ebb4b7","topic":"I/O控制方式","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-39db04436ae9b5.svg"},"children":[{"id":"f69abaa24c28418f41329befc4","topic":"程序直接控制","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"da3b7fc4637b892c1f97e83885","topic":"图：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"6f36e1fb-ed09-4ab6-8109-71e6b812c618","topic":"图示","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-5cf7eabd06d185.png","width":299.32,"height":388.05},"children":[{"id":"503df6f3-de26-4227-9438-03c57042ab0c","topic":"CPU不停的进行轮询测试","expanded":true,"style":{"background":"#FDD834"}}]}]},{"id":"2d9976145c298dd541b53893f0","topic":"CPU干预：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"645eb6d5-05ee-4a03-b9f6-5f019cb16ff6","topic":"非常大","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"3868eaf2edebf3d903cd89f77a","topic":"读写单位：","expanded":true,"children":[{"id":"2f381e60-c5f3-4fa4-a437-dbe3b8ebe12c","topic":"字 word","expanded":true,"children":[{"id":"a9a9fb58-117b-49d7-97ba-9432703da3a1","topic":"NOT 字节byte（因为读取的单位是按数据总线的位数决定的）","expanded":true}]}]},{"id":"da5a0cf73e9b2eec790c3a321c","topic":"数据流向：","expanded":true,"children":[{"id":"0ad78f2c-5dfe-43f2-b954-984f676a7801","topic":"I/O控制器 -> CPU -> 内存","expanded":true}]}]},{"id":"1eea4eafda79e1b68df47b4dc5","topic":"中断驱动方式","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"181b169f2d0a7f2074e13a7dd2","topic":"图：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"0d19a901-bf10-44d6-b819-1f7d06927d1a","topic":"图示","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ae5009cb96313b.png","width":194.06,"height":378.76},"children":[{"id":"aab2a43c-ec0f-41b1-98f3-b069f8da550d","topic":"CPU中断去做其他事情","expanded":true,"style":{"background":"#FDD834"}}]}]},{"id":"97f8fc6dbf1a0eb096bb284ae3","topic":"CPU干预：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"33cbd714-16e6-4464-b092-4bb4ff7837d2","topic":"不高，可以切换到其他进程","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"a8fad1e0ea2a32f6bc966a689b","topic":"读写单位：","expanded":true,"children":[{"id":"7911b462-e607-46c4-bd30-6a9ab049d84c","topic":"字","expanded":true}]},{"id":"27189935568b7dcf16d6d9d19d","topic":"数据流向：","expanded":true,"children":[{"id":"561cc890-8e5e-4f34-9acc-93f98eb94d7a","topic":"I/O控制器 -> CPU -> 内存","expanded":true}]},{"id":"d0a88e1195ebd047168b7979d3","topic":"何时检查中断：","expanded":true,"children":[{"id":"7472e0db-9feb-472d-a6af-75f4521ae41a","topic":"在指令周期的末尾的时候进行检测","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"52fab144b92b0a69efdd782611","topic":"中断时，CPU：","expanded":true,"children":[{"id":"f1c2bf31-b974-4363-9823-afd666b73808","topic":"保存在执行程序的上下文，然后去执行中断处理程序","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"6c4ac94c011ad843b21819d3dc","topic":"DMA方式","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"8bdf8dfe-4341-4083-8b2d-58629a224959","topic":"图：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"63fd3a20-7b97-47c2-8824-3b90b2ff0dee","topic":"图示","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c540ad2b4672d6.png"}}]},{"id":"8b69b54ee7fadf9bef7ada1f8b","topic":"DMA控制器的组成：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"0203f08c-6604-4c17-94b4-e5ea354d0b66","topic":"图示","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-eb0255b53cd2bb.png","width":529.02,"height":207.75},"children":[{"id":"b17956e6c9e87de7fae76b9b90","topic":"四个寄存器的作用：","expanded":true},{"id":"34dd60bc-4bda-425d-ab17-5fc3a65199ec","topic":"DR：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"16305bf5-cfaa-48ea-8946-fae971e34ef9","topic":"Data Register，用于暂存设备和内存交换的数据","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"d9e00c90-8f52-4d5b-ac15-136c129bdddd","topic":"MAR：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"0adb6c7d-75fa-41ee-81b0-727bf3bc5186","topic":"Memory Address Register，指明内存的起始地址","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"2070b83e-b419-4b33-898c-a2b71baad01c","topic":"DC：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"8ee5a0d9-bb6b-48e0-b39a-df86924b3ef7","topic":"Data Count，存在本次要传送的字数（或字节数，都可以）","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"6feecaa4-56bd-400e-b1fa-248bf0d139d7","topic":"CR：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"017b9644-5de9-44c0-a48d-792951bb6a6d","topic":"Command Register，用于接受CPU发来的命令","expanded":true,"style":{"background":"#8EDE99"}}]}]}]},{"id":"7fe929e95c3b100d5b4fea3449","topic":"CPU干预：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"7a3061f8-b880-4b97-9568-131fc53c0191","topic":"很低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"662aa101-8021-4958-824c-c1b7d2af1116","topic":"CPU指明内存的哪个部分和磁盘的哪个部分需要进行数据交换","expanded":true}]}]},{"id":"c3aae8e9f08b2db7183e6a685d","topic":"读写单位：","expanded":true,"children":[{"id":"1663cac2-6ac6-4249-9412-ecfe28eb7db8","topic":"一个块","expanded":true}]},{"id":"b2fbbd9ae978c7c5a8653a35e1","topic":"数据流向：","expanded":true,"children":[{"id":"884b5f79-235b-4b3b-9ea2-40e006a71a08","topic":"内存 <-> I/O","expanded":true}]},{"id":"ad6b6e7016886067bc48885c40","topic":"缺点：","expanded":true,"children":[{"id":"6c5bf547498acc960b36dab233","topic":"一次只能读一个/多个连续块","expanded":true,"style":{"background":"#FF9595"}},{"id":"94b98d7d124bf0bd24fa3be663","topic":"读写多个离散的块很麻烦","expanded":true}]},{"id":"25d03a6b-6587-44a7-9d20-7660c828fce2","topic":"例如：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"ef34e640-ec67-496b-8e94-1c0df1936598","topic":"磁盘","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"4ad8efc5950a82da6390e8a9a9","topic":"通道方式","expanded":true,"style":{"background":"#D0D0D0"},"children":[{"id":"d77dbf88-9618-4d44-beab-666d9626968b","topic":"通道技术是一种硬件机制","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"70cec1d9-e6f5-4900-8d53-dfcbee8ac6b8","topic":"在计组中有学，例如有通道三总线模型等等","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"2c62cf05-c5d6-43ac-8aab-d825b79e6067","topic":"将众多指令直接编写在通道文件中，CPU交付于I/O处理，I/O将指令执行完成后再通知CPU","expanded":true,"style":{"background":"#FDD834"}},{"id":"2d4b8105-9e5f-43f9-aeb2-4fbc033126ab","topic":"又称为","expanded":true,"children":[{"id":"93e3ab4e-e576-4544-841b-842d17588077","topic":"I/O处理机","expanded":true}]},{"id":"6b385483279a9462c1a2d95339","topic":"CPU干预：","expanded":true,"children":[{"id":"c74a1055-3ed3-4ac7-a088-1e89bdae785c","topic":"最低","expanded":true}]},{"id":"163acf5575c901fc2208288046","topic":"读写单位：","expanded":true,"children":[{"id":"aa98e46f-7639-410e-a154-a0d161bea440","topic":"多组连续的块 = 一组离散的块","expanded":true}]},{"id":"fdebef6076ea6d2f1498e87d02","topic":"数据流向：","expanded":true,"children":[{"id":"11c5e0b9-7856-4cd3-b02d-69facf496d59","topic":"内存 <-> I/O","expanded":true}]},{"id":"16a6924c-b244-41d7-9145-e48d47544d75","topic":"通道分类（拓展）","expanded":true,"style":{"background":"#D0D0D0"},"children":[{"id":"a5bd5036-29ab-4742-94e2-dba2bd703230","topic":"字节多路通道","expanded":true,"children":[{"id":"6c911c37-eb05-4e36-993e-f0c3c966e2c0","topic":"大量的低速、中速I/O设备","expanded":true}]},{"id":"131ce963-4a97-48e6-ab61-531a96261575","topic":"数组选择通道","expanded":true,"children":[{"id":"00d72e6f-ef38-4eaf-8a0d-475317f1dbd7","topic":"少量的高速I/O设备","expanded":true}]},{"id":"ac748b46-02f1-4de7-a0bd-61906dd75b97","topic":"数组多路通道","expanded":true,"children":[{"id":"8405e704-917f-4d7f-bc04-9fdb5c439333","topic":"大量的高速I/O设备","expanded":true}]}]},{"id":"93399750-f444-4a04-a1b7-f40215c34255","topic":"通道控制设备控制器，设备控制器控制设备","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"d6b2edf6-76dd-4a6f-93c5-7881ef258c8d","topic":"DCT、COCT、CHCT、SDT","expanded":true}]}]},{"id":"a7deafe4-e47b-48a0-b5b7-ffd13455a0c7","topic":"总结：中断时机","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"bb82009d-6c16-4672-aa9f-583c90d78c35","topic":"程序直接控制方式","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"d87816d5-4dd9-41f2-ac07-0b520c610757","topic":"没有中断：CPU定期轮询检查I/O操作是否完成","expanded":true}]},{"id":"ede161f2-52a8-4ead-8604-a021979e9941","topic":"中断控制方式","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"dd0544c0-fe21-4051-828f-5b28b409f359","topic":"中断发生的时机：每完成一个字的读写（CPU完成的读写），I/O控制器向CPU发出一个中断信号","expanded":true}]},{"id":"936a9e65-f923-4c41-928c-1edbc12bc677","topic":"DMA控制方式","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"d129f84a-198f-42a7-bc77-9936a0c38097","topic":"中断发生的时机：CPU向DMA控制器指明读写操作相关参数，每完成一整块数据的读写（DMA完成的读写），DMA控制器向CPU发出中断信号","expanded":true}]},{"id":"dda52e9e-0ddc-41ff-9fe3-9411a38b6e0d","topic":"通道控制方式","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"34a23382-13e1-42d3-9e15-be7d4736f691","topic":"中断发生的时机：CPU向通道指明通道程序在内存中的地址，通道执行完通道程序后，通道向CPU发出中断信号","expanded":true}]}]}]},{"id":"40fa0fc48949c07e0324d97904","topic":"I/O软件层级结构","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-0eb260ceca6ca7.svg"},"children":[{"id":"edc5492e-2276-4ad1-b71e-caf80e698d19","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"5bee01d3-8729-47c5-a7fc-03fa76721260","topic":"10-13、17","expanded":true}]},{"id":"b4722863-e7a9-4530-b753-77792548f41f","topic":"一共有五层","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"2a9817fd-f7fc-4c30-860d-9da1f08b9c3d","topic":"用户层I/O软件","expanded":true,"style":{"background":"#FF9595"}},{"id":"f54fb409-a159-45ec-8673-c2514d52f95d","topic":"设备独立性软件","expanded":true,"style":{"background":"#FF9595"}},{"id":"cd29cdfd-2929-4a4c-bc3a-823fd57b3a2e","topic":"设备驱动程序","expanded":true,"style":{"background":"#FF9595"}},{"id":"effd6a0e-dd21-4301-b5b0-6fdfb69c72de","topic":"中断处理程序","expanded":true,"style":{"background":"#FF9595"}},{"id":"6e787a53-f80f-46b4-a026-a31bfb51b66c","topic":"硬件","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"63d81ed47f0ae2e06523b88f2b","topic":"用户层I/O软件","expanded":true,"icons":["priority:1"],"style":{"background":"#FDD834"},"children":[{"id":"c33a03d6878987455077a9aa39","topic":"向上：","expanded":true,"children":[{"id":"6a89b221ee7a2e450a70eb02ef","topic":"实现和用户交互的【接口】","expanded":true},{"id":"24fb4a373769a8f1f6c84b22a3","topic":"可以直接调用提供和IO有关的【库函数】","expanded":true}]},{"id":"6f9a8755b72a48fb1c9379eae6","topic":"向下：","expanded":true,"children":[{"id":"13b9ab97993a1202258b5b8135","topic":"将用户请求【翻译】为格式化的IO请求，通过【系统调用】请求OS提供服务","expanded":true}]}]},{"id":"1b9a870115f9def009186847be","topic":"设备独立性软件","expanded":true,"icons":["priority:2"],"style":{"background":"#FDD834"},"children":[{"id":"503b1a83982bf9961837996622","topic":"又称：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"25faccfeca6bf75dc39e990cad","topic":"设备无关程序、系统调用处理程序","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"63b8ea6a51d8197eb5de5ab851","topic":"向上：","expanded":true,"children":[{"id":"2c7a70a4689a904c1f01f90152","topic":"提供read/write调用","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"06346a29-70c4-40fc-b550-36ba44a16220","topic":"即提供把系统指令翻译为设备操作命令","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"30da8690ba4bf239fe9d7b732b","topic":"提供设备保护","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"c2d1b502-d25b-4947-8f52-8dd434338e96","topic":"即文件保护","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"26a94c49c729bb5c2c968b7638","topic":"差错处理","expanded":true,"children":[{"id":"f18c97c4-2eaf-4af9-9337-a516b2f4b885","topic":"不会考","expanded":true}]},{"id":"cfda5f5084da85cc366e8acd4f","topic":"设备分配和回收","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"1e2011d8-e587-463f-9c09-382fd71d74b1","topic":"即文件的分配与回收","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"823a58c132eab6b7bdd57a433c","topic":"数据缓冲区管理","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"756f1ea2-b8c6-4a4d-bc6d-3ec556be2dd4","topic":"屏蔽设备之间的传输差异","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"3f58ae3de4a8a04cff0e18e4cb","topic":"建立逻辑设备名","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"6fe156d6-91e2-497c-a6e0-76aa42bb0cf1","topic":"逻辑设备名是用户提供的，而设备只有物理设备名，故系统中有一个LUT(Logic Unit Table)逻辑设备表来根据逻辑设备来映射到一个物理设备上","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"df1cffc6-424e-4b95-bc30-e41e9d443ccd","topic":"LUT存在每个用户的PCB中（在多用户中）","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"ccee014c-8697-4a5d-9953-e9f560807a2a","topic":"使用逻辑设备名的好处","expanded":true,"children":[{"id":"d95595a5-c14f-4e49-a940-f4f95245c5f5","topic":"增加了设备分配的灵活性","expanded":true},{"id":"64e30ed0-db24-4004-9221-ceeab47c9d41","topic":"易于实现I/O重定位","expanded":true}]},{"id":"52b8f445-ff54-44a1-a352-0be5df739ae1","topic":"LUT在有些题目中又叫做DMT(device mirror table)","expanded":true,"style":{"background":"#FFABD5"}}]}]}]},{"id":"5de4e21b-28ca-4c10-9bb1-0c52328cff48","topic":"计算机在对一个设备进行了区分和识别过后，会分配给它一个”绝对号”","expanded":true,"style":{"background":"#FFABD5"}},{"id":"3d4363f8-37ce-4392-93af-9c4f93798978","topic":"高速缓存、SPOOLing技术等也是这个部分的知识点","expanded":true,"style":{"background":"#BA69C8"}}]},{"id":"278a7f38ad7a6e3d44c9fa401f","topic":"设备驱动程序","expanded":true,"icons":["priority:3"],"style":{"background":"#FDD834"},"children":[{"id":"b77b0bc274bb77fb38ec0afaf2","topic":"例：","expanded":true,"children":[{"id":"537931354f99be5155adcaafec","topic":"第一次插上键盘，安装”驱动程序“","expanded":true}]},{"id":"948c4bcc-0546-40b5-abc9-f4ade6087372","topic":"根据商家的驱动程序，把逻辑地址转为物理地址","expanded":true,"style":{"background":"#FDD834"}},{"id":"29c6fd60-6c4c-4809-9a98-682ab848c1c3","topic":"每一类设备需要设置一个驱动程序","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"c84809a8-ade9-46eb-9746-4d1fd33028ee","topic":"例如系统中有2个绘图机3个打印机，只需要两个驱动程序即可","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"9159898c0589fe90f2e1e9a8da","topic":"中断处理程序","expanded":true,"icons":["priority:4"],"style":{"background":"#FDD834"},"children":[{"id":"f4a96ee70ea904a2c13acbc8b2","topic":"用来保存被中断的CPU环境","expanded":true},{"id":"e4c1eabe-d870-495f-a315-10668b84b85a","topic":"执行进程上下文的切换、对中断信号进行测试、读取设备状态和修改进程状态","expanded":true}]},{"id":"062b7833e3fa9dfb2ac688aa6e","topic":"硬件设备","expanded":true,"icons":["priority:5"],"style":{"background":"#FDD834"},"children":[{"id":"9ce9abbcf3c82d1d5e7fd826fe","topic":"两个部件：","expanded":true,"children":[{"id":"832b31c07a2ad355e0c029d92f","topic":"机械部件","expanded":true},{"id":"39b9b83928b832b6d4904af2e5","topic":"电子部件","expanded":true,"children":[{"id":"84f708c4-9d50-4179-9246-30c543a5db30","topic":"设备控制器（设备适配器）","expanded":true}]}]}]},{"id":"bd883cd396f8bb8af7dc5bf176","topic":"I/O子系统概述","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ca59f6498b6110.svg"},"children":[{"id":"e03845b06bf928144a9cbae597","topic":"层次：","expanded":true,"children":[{"id":"751bca38c2ea00d45d921ac6a7","topic":"设备无关性软件","expanded":true,"children":[{"id":"a9a6a886-8c78-46f9-a0e1-16a398b0fa88","topic":"逻辑设备到物理设备的映射，也同样要找到设备的驱动程序","expanded":true}]},{"id":"1d8b39e7bd3987cb84453980eb","topic":"设备驱动程序","expanded":true},{"id":"52d8afd96d0ade54872d3b08b7","topic":"中断处理程序","expanded":true}]},{"id":"f46af7e377e921b1e706b875ef","topic":"功能：","expanded":true,"children":[{"id":"0c59cb172f3b399e338ef869cf","topic":"I/O调度：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"83e915272e09e7c3d8df8acd1e","topic":"磁盘调度算法（打印机也可以用","expanded":true,"style":{"background":"#FF9595"}},{"id":"c94edefa-0f3c-41f7-a037-5992ef0976bb","topic":"OS开发人员为每一个设备都维护了一个请求队列来实现调度","expanded":true}]},{"id":"548bb41b2d38a108ed8b4ad636","topic":"缓冲与高速缓存：","expanded":true,"children":[{"id":"f21954fc05c9fcd1266dbb7826","topic":"缓冲区","expanded":true}]},{"id":"6469a41b7c4bbded4033d856cf","topic":"设备分配与回收：","expanded":true,"children":[{"id":"9008c0a32358192ecf374b4e78","topic":"文件的分配和回收","expanded":true}]},{"id":"cf9ac000541ac04e366c69ceeb","topic":"假脱机：","expanded":true,"children":[{"id":"7b7b685c1a3853b44599ab8219","topic":"SPOOLing技术，在I/O子系统层中，现实生活中在用户层","expanded":true}]},{"id":"f7a8bd847a5b3ea2b2c2ab65ef","topic":"设备保护：","expanded":true,"children":[{"id":"038aa2ddc759403d99b44bd514","topic":"文件保护","expanded":true}]},{"id":"94b9b166d2ea1bb665a8599f09","topic":"差错处理","expanded":true}]}]}]},{"id":"5989ad1ce1b8cd9ce3de0a5c08","topic":"高速缓存和缓冲区","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-249db71a608952.svg"},"children":[{"id":"3d3919179c0bc35fbd247aa7d3","topic":"磁盘高速缓存","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"0299b6bb-aa5a-4b8e-8123-9b0a9ef4ab0e","topic":"Disk Cache","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"2a9b8373d6792fcb4c74cb33c7","topic":"概念：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"50da86399719dcc445993a739b","topic":"将一个指令又存在内存中，又存在磁盘中","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"5f5249ca-f431-4338-84fc-254b05f894c2","topic":"作用：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"899d8d08-ed27-4afc-9499-e538ad9f830e","topic":"提高I/O的速度，访问更高效","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c0619a05-baab-4ca2-af83-090f280fc8df","topic":"例如进程的指令既在磁盘中，也在内存中，同时还在CPU一级二级cache中","expanded":true}]}]},{"id":"0a59a4ac3b287feb628dd89b93","topic":"形式：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"4dabbef781dba18ba08bfa9cf0","topic":"1. 在内存中【单独开辟空间】，大小固定","expanded":true,"style":{"background":"#8EDE99"}},{"id":"eb68a188dcf9164a87cfdac332","topic":"2. 把未利用的内存空间作为【缓冲池】，供请求分页和IO共享","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"694897136dd86209129f08ecda","topic":"缓冲区","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"afa9fcbdf49a8cb843bd2b752f","topic":"目的：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"f468bfb90909f5cb226d583146","topic":"1. 缓和CPU和I/O的速度矛盾","expanded":true,"style":{"background":"#8EDE99"}},{"id":"4cf86985f459c52237b24aab7e","topic":"2. 减少CPU中断频率","expanded":true,"style":{"background":"#8EDE99"}},{"id":"3c3a450b0d9bb66c11148a6be4","topic":"3. 解决数据粒度不同","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"a9c02467-14b3-409c-b0a7-578b4c210718","topic":"例如CPU一次产生一个块，I/O一次只能读一次char","expanded":true}]},{"id":"8289c1bbeb0a725188e77bc992","topic":"4. 提供CPU和I/O的并行","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"d58a8220-c5fe-4376-ac0b-5fbff3a34b61","topic":"实现方法：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"860c1fd2-2d52-4728-bab3-423c11553e56","topic":"使用硬件缓冲区，成本太高，一般不用","expanded":true},{"id":"4e441a19-f377-42d0-8bd5-2e7783449ad9","topic":"采用内存缓冲区","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"f48872dc-639c-41e4-8436-891ab6a2a2a7","topic":"采用缓冲技术","expanded":true}]}]},{"id":"3ebc2c8f-6b43-47c3-8a00-794f22682a29","topic":"需要缓冲的例子：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"ffdd739d-4ae5-4241-a545-c402af37a559","topic":"鼠标、键盘","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e86a5d42-245a-4df4-811e-8f4035f75f12","topic":"若有更高优先级的进程到来，鼠标点击事件不应被丢失，则放在buffer中","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"e38d7250-aeeb-4d3b-912d-dc0620e01121","topic":"多任务的磁盘驱动器、磁带驱动器","expanded":true,"style":{"background":"#FFABD5"}},{"id":"57262a4d-6c44-463e-956e-b2115acb360c","topic":"图形卡","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"39079276-0154-4dc8-88f4-7d4495b2ee4f","topic":"图形学开篇，使用双缓冲来实现图像更换","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"b456ebea-3a06-4e30-b803-5982cf95dcb9","topic":"若无特殊说明，缓冲区大小为一个块","expanded":true},{"id":"2ca2d4d1-0f44-4ef7-bcce-db82c1d58eaa","topic":"高速缓存和缓冲区的对比","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"9bc2283d-cb30-46cc-909a-6e26da60c0d3","topic":"图示","expanded":true,"style":{"background":"#FF9595"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-3d9608091b5852.png","width":624.25,"height":170.39}}]},{"id":"59ade475-22e3-47eb-819e-3f49a4734bec","topic":"预读 + 滞后写","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"ab6344db-2137-4114-9cc1-65f116aeae4c","topic":"预读：读区域A的时候，把A的下一块也同时读入到buffer中","expanded":true,"style":{"background":"#FFABD5"}},{"id":"19ee04b0-e52c-4664-8c76-1980e5a2aed7","topic":"滞后写：在需要把A写回时，先不写回，先挂载到buffer中，直到这块buffer需要使用再写回","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"09c9e6027959818f0e77caa61a","topic":"缓冲技术","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"0a8b03bd-9cfa-48d3-8d39-1434482de10d","topic":"注：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"4b614beb-72f2-45eb-8cd3-289b13b207ee","topic":"下图中计算周期时假设的是工作区已经满了，所以设备 -> 缓冲和工作区 -> CPU可以同时运行，如果初始情况为空：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"f0275293-4534-4e3d-aea7-3694c7367816","topic":"图示","expanded":true,"style":{"background":"#FFABD5"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-3387a4ae309fe2.png","width":414.19,"height":165.45}}]}]},{"id":"9fbb23d2a3fa7bb17f548b672e","topic":"1. 单缓冲","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"4f8b2a44d23ae46d16a81b3d71","topic":"流程图：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"62178fd5-a3a1-4a7f-aa36-a8e8299e8fa5","topic":"图示","expanded":true,"style":{"background":"#FF9595"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8200603473401d.png","width":260.49,"height":210.73},"children":[{"id":"d9a62e35-a135-48c3-815b-9b99da7a9c25","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-b3bea6cc86f543.png","width":403.48,"height":315.02}}]}]},{"id":"056aab5c56aa3a2977c2c93354","topic":"描述：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"35e1176d-9d9e-4d3b-8d3f-12629c5802fd","topic":"开始状态缓冲区的数据为空，工作区数据为满","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"a122091e-1cc7-474e-8cd6-c1b4dc3db650","topic":"CPU处理工作区时间为C，设备把数据写入到缓冲区的时间为T","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"3d3afb0f-7606-4cde-89df-8472a844c42c","topic":"缓存区写满 + CPU处理完毕后，然后缓冲区中的数据传入到工作区中（不由CPU参与）","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"124af6469db8d3ec5219db189b","topic":"2. 双缓冲","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"8288340fe8db6dbc410deaa344","topic":"流程图：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"f805b1bd-66d1-46d1-82ff-9212138258f5","topic":"图示","expanded":true,"style":{"background":"#FF9595"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-a25e6b18bd9e16.png","width":383.95,"height":217.92},"children":[{"id":"4793fd4d-4775-46c7-93aa-6645747295c1","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-920754f9af3f47.png","width":405.02,"height":470.2}}]}]},{"id":"054260f1-038f-4135-bd8c-3ed3548f5ed1","topic":"描述：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"688ab472-5c48-4269-8b59-8eb83d305c77","topic":"假设开始状态，工作区为空，缓冲区A为满，缓冲区B为空","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"b884c34d-e8ac-4e77-a8cd-0d83bdbf074e","topic":"那么可以同时进行 ：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"b01aca75-cd93-4138-927d-83076fc239a0","topic":"缓冲区A -> 工作区（时间M）","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"09699738-bb6b-4910-8aaf-421cada5da6d","topic":"I/O设备 -> 缓冲区B（时间T）","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"7be2ee9f-9697-4b15-9d56-6aa15a1a4067","topic":"根据上述情况做完以后来进行CPU对工作区的处理（时间C），根据这个时间的长短来决定周期","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"e8179c6c-bf9d-48ad-b9e9-ed1cc7cbc04d","topic":"缓存通信","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"baa3b1f9-63f4-477f-af60-7ef99f61b4ca","topic":"如果两台机器都只有单缓冲","expanded":true,"children":[{"id":"5e12b5d9-7480-43fb-bf40-55174d9d7826","topic":"只能单向传输","expanded":true,"children":[{"id":"5e07cd0d-9473-4c05-9cc0-21fc1e454130","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-2d97c5af6b3014.png","width":174.18,"height":144.88}}]}]},{"id":"f26ed7e1-f3cb-418f-b047-a2e3f7ec56e8","topic":"如果都有双缓冲","expanded":true,"children":[{"id":"bc49dc7a3739afb72722695183","topic":"可以实现双线传输","expanded":true,"children":[{"id":"b611e90a-bcc7-4743-a1f3-efeb9ffb363a","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-420d7b9d820532.png","width":188.09,"height":151.08}}]}]}]},{"id":"b28a3ca27e8ab8485c69c9fa47","topic":"”管道“通信：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"473bb6a845893004ce5dbb5009","topic":"”管道“通信就是一个缓冲区，要实现双向通信，就需要两个”管道“","expanded":true,"style":{"background":"#FDD834"}}]}]},{"id":"6278d17bfbd870f5be66b940e5","topic":"3. 循环缓冲","expanded":true,"children":[{"id":"214b7499509af789bccd1bc02e","topic":"流程图：","expanded":true,"children":[{"id":"c752ab84-d6c9-4f07-af3e-52a4aa72fa43","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-796a7a8542e1ae.png","width":142.24,"height":169.75}}]},{"id":"48aa7df3243a2817b10b1b1a07","topic":"描述：","expanded":true,"children":[{"id":"33631286-8d5e-446b-90f1-e907baeb58a4","topic":"包含多个大小相等的缓冲区，形成循环链表的形式。另外有两个指针in/out，分别是输入指针和输出指针。in指向空缓冲，out指向满缓冲","expanded":true}]}]},{"id":"d87ad8f16d5b35e3daf48a03c6","topic":"4. 缓冲池","expanded":true,"children":[{"id":"e9e8f33cb309c987a381a931fb","topic":"组成：","expanded":true,"children":[{"id":"5f9ba2cccd8ba7a867dfca7fe6","topic":"多个公共缓冲区组成缓冲池","expanded":true},{"id":"d7cc4b40-f185-42a9-b8fe-e25dbdec9ead","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-39f53f9db891cb.png","width":307.42,"height":190.4}}]},{"id":"0be9f452fc8a0552ecde19d751","topic":"三个队列：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"aad8614d4f1a03c3f0051bedda","topic":"空缓冲队列","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"c49a0a68fe6bb5cdcbf64a65d9","topic":"输入队列","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"3f8abe89848a3670efb45bfe4d","topic":"输出队列","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"f21bb3de610b6f2948c9eb6e60","topic":"四种缓冲区：","expanded":true,"children":[{"id":"01ca5b0e8ad989e2dfca2a96f0","topic":"收容输入数据缓冲区 hin","expanded":true},{"id":"95c83271238af6a12c5afb6266","topic":"提取输入数据缓冲区 sin","expanded":true},{"id":"58a996bdb19883058a227a7902","topic":"收容输出数据缓冲区 hout","expanded":true},{"id":"f7da624fc2eaffd9ce22f8b126","topic":"提取输出数据缓冲区 sout","expanded":true}]},{"id":"bf0b94f0ef881cd19458481e4d","topic":"四种操作：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"17fab5221d5a7009bfe5e891d4","topic":"输入进程进行输入：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a3a85352b62a111e5bbf9befe2","topic":"从空缓冲队列中提取一个缓冲区，将其作为hin，把数据输入，“装满后”挂到输入队列队尾","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"928af698c37949fd94a4290443","topic":"计算进程读取输入：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"349a94f42c787702c5c9bbc21a","topic":"把输入队列队首缓冲区提出，作为sin，用完后把它挂到空缓冲队列中","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"2b0bddaff689965ef0cc099e55","topic":"计算进程提供输出：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"98face90efb983aaaad2b929e3","topic":"从空缓冲队列中提取一个缓冲区，将其作为hout，把数据输入，“装满后”挂到输出队列队尾","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"a7faba31676b965df2f6f90b70","topic":"输入进程获得输出：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"ea9b2b4c100913be83361a6aa1","topic":"把输出队列队首缓冲区提出，作为sout，用完后把它挂到空缓冲队列中","expanded":true,"style":{"background":"#8EDDF9"}}]}]}]}]}]},{"id":"69aa754371398475972fdbd2ab","topic":"设备的分配和回收","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-127eb26f8b6f75.svg"},"children":[{"id":"6459f14d00caae9d91f27823f6","topic":"三种分类：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"dbdbfa2f223b3d8c661089c58e","topic":"独占","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"1b6b6272fee8c3f861b09bd924","topic":"打印机","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"cdfabc0ced893a05ea530a1adc","topic":"共享","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"0b1a24f410bb5d2bb0620a92b1","topic":"磁盘","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"a4186b92bb79d6dd8b267852a1","topic":"虚拟","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"301b1cb4e85925fa2075e90997","topic":"SPOOLing技术","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"8fc830a1ce499dc9a9e2d9a319","topic":"数据结构：","expanded":true,"children":[{"id":"6a6b175405f98a06c548e89cd2","topic":"DCT：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"d4412508-2e42-4038-be0f-6a38368f0c8b","topic":"一个DCT表就表征一个设备，表中内容就是设备的各个属性","expanded":true,"style":{"background":"#FDD834"}},{"id":"9a8a7b91657ac6be2f304b7e8f","topic":"称为：","expanded":true,"children":[{"id":"173a65246f580fcfbdc1a88c41","topic":"Device Control Table 设备控制表","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"c2d9bd4d13c81c2cd388a9adad","topic":"内容：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"1afbad6ff7d925a105b619452f","topic":"设备类型type","expanded":true,"style":{"background":"#8EDE99"}},{"id":"8bb9db3ab12bdabf36e42bba5b","topic":"设备标识符: deviceid","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"43dcd2d2-eac8-4c99-afa3-dad500e3b9f0","topic":"唯一id","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"51c87211f4986f1b73c059b957","topic":"设备状态：等待/空闲","expanded":true,"style":{"background":"#8EDE99"}},{"id":"e46ab6a287489435c5f6eadb2a","topic":"指向控制器的指针","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"97671b39-a5af-4bab-a1dc-62448ded613a","topic":"用来找该设备对应的I/O控制器","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"0b4d94f4-cd2c-424e-95a1-f2ee54418c6e","topic":"父级指针","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"1d0a0b9fa91b01df9437a8bb69","topic":"重复执行次数或时间","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"1aeef6f7-7934-418f-8c1b-d3716952f03c","topic":"I/O设备会在自己发现执行失败了很多次以后才会认定为I/O失败","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"c0a9b4b10439ded45b40980d5d","topic":"设备队列的队首指针","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"4dd7beb1-c642-4d4d-b40d-2accdb41323f","topic":"指向正在等待该设备的【进程队列】","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"d25d90fb-6759-463f-a516-18e4fcfcbe2a","topic":"如果一个进程想要使用这个设备，那么就把该进程的PCB插入到该设备对应的DCT的设备队列中","expanded":true}]}]}]}]},{"id":"1949383e768ba8ad6ade98bf3e","topic":"COCT：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"8c027947-a2bf-4e05-bc35-411eb8534619","topic":"用来管理众多DCT，因为【一个控制器会管理多个设备】","expanded":true,"style":{"background":"#FDD834"}},{"id":"e91822e3198a616a419bea52d1","topic":"称为：","expanded":true,"children":[{"id":"30d928cdf6299d88ddb2fabcfe","topic":"Controller Control Table 控制器控制表","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"529b8fb845296efa501e8b1f3d","topic":"内容：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"d18a57de6fd8bccd3d6efab8f0","topic":"设备标识符: controllerid","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"e0a9c4a5c7887eaf328abb4759","topic":"设备状态：等待/空闲","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"04e8b5bf6ea800d00fa87b3ac3","topic":"指向通道的指针","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"3f2e6c1b-e4b3-4fd4-9e30-a29b1a1a65e0","topic":"父级指针","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"c4a865d716a932a8c2beea7671","topic":"控制器队列的队首指针","expanded":true,"style":{"background":"#8EDDF9","fontWeight":"bold"}},{"id":"d5fb12b89b193509c6137b4481","topic":"控制器队列的队尾指针","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"af5a288d8c6a0d3e57875a6103","topic":"CHCT：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"f32ec7bc-215b-4359-a525-43798c2d7e41","topic":"用来管理众多COCH的，一个通道管理很多个控制器","expanded":true,"style":{"background":"#FDD834"}},{"id":"37aae4ed6ac95ea883b019b30c","topic":"称为：","expanded":true,"children":[{"id":"d61bc2d31f29f087348a2ab9b7","topic":"Channel Control Table 通道控制表","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"46ab93b882fb6d8041ec8a2e75","topic":"内容：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"771a630ea429595157392a1ae7","topic":"设备标识符: channelid","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"09ca965415898d2dd0c418b112","topic":"设备状态：等待/空闲","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"d1ca16b6513b8137bd6e4ac104","topic":"控制器队列的首地址","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"31799c79-52cc-4faf-a5d3-2eec1453e4e1","topic":"孩子节点，找到第一个相连的控制器","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"e8a9b267dd59a81c0434bbb092","topic":"通道队列的队首指针","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"d28a74124fc8e3b300dbc99b39","topic":"通道队列的队尾指针","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"85e992bb1488ab7eb20dda63ec","topic":"SDT：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"9ac2e194-2bf7-4d8e-85ce-11b4a2073f9c","topic":"整个系统只有一个SDT表，管理所有物理设备","expanded":true,"style":{"background":"#FDD834"}},{"id":"d59bd153cfd9247303fc98966f","topic":"称为：","expanded":true,"children":[{"id":"497aef22aef87005e19ffb5767","topic":"System Device Table 系统设备表","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"5cbb79b8a5f81e8b9b99cb0e35","topic":"SDT是一个表，每一个设备就占一个表项（前面的同理）","expanded":true},{"id":"0e1a64077258dad4e104081e78","topic":"内容：","expanded":true,"children":[{"id":"9119ad5757abd8dad0e9aa8baa","topic":"设备类型","expanded":true},{"id":"f8e94da0e1da09fd176b8b003b","topic":"设备标识符","expanded":true,"children":[{"id":"82f81170409a461d497a69a468","topic":"物理设备名","expanded":true}]},{"id":"ecda60f27a8afcbc2901f969de","topic":"DCT","expanded":true},{"id":"8e1b0663dbfae058293aa8f437","topic":"驱动程序入口","expanded":true}]}]},{"id":"3cd9ba91-b6eb-4d09-b597-c4b6be5eb284","topic":"设备分配的步骤：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"7847d543-8ef3-40d0-950b-e9244b228e39","topic":"1. 根据进程请求的【物理设备号】去查SDT的【设备标识符】，获得对应DCT","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"f87ee7a8-0246-43d5-9b97-d244d1013ed1","topic":"如果请求的是【逻辑设备号】，就去查SDT的【设备类型】","expanded":true}]},{"id":"4979a580-db05-42b9-8a9f-4f193f077100","topic":"2. 找到DCT，如果设备忙碌(【设备状态】)就挂到等待队列，如果不忙碌就获得该设备","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"d3c3d563-1ad4-4211-bcd3-c168b9fb5dff","topic":"将该逻辑设备的<逻辑设备名、物理设备名、驱动程序入口地址>加入到LUT表中","expanded":true}]},{"id":"8ef8c4a1-7f36-4f4f-a97b-a69ceb362bb5","topic":"3. 根据DCT去找【父指针】，找到COCT，控制器忙碌就挂，不忙就用","expanded":true,"style":{"background":"#FF9595"}},{"id":"8cb51a5c-9410-42c9-aaa2-bc9b0f5d20bf","topic":"4. 根据COCT去找【父指针】，找到CHCT，忙挂闲用","expanded":true,"style":{"background":"#FF9595"}},{"id":"de6844ba-7288-40af-8602-a89c8b456562","topic":"只有上述四个步骤都分配完成才算成功","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"ecf05c35-d25e-4290-8e2f-942bd26a7d05","topic":"使用【物理设备号】请求不如【逻辑设备号】好","expanded":true}]}]}]},{"id":"c5ca7ab73e59bec4b0672b893b","topic":"设备分配策略：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"a0791d41d64b99b424bcf95114","topic":"设备分配方式：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"5799a2e8942b20ea95e6f8cd6f","topic":"静态分配","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"330ab4ae843a0e1ec46289dbe8","topic":"作用：","expanded":true,"children":[{"id":"f5ab899ae40bfa9f06c0f9d70b","topic":"OS一次性分配该作业需要的所有设备、控制器、通道信息","expanded":true}]},{"id":"e83a601c837b138c4379a95f5e","topic":"死锁：","expanded":true,"children":[{"id":"17ca46234f4bb929a8e0c89be3","topic":"不会”死锁“，破坏了”请求保持“","expanded":true}]}]},{"id":"d59a6b1900e919f073376808fe","topic":"动态分配","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"9fe9a912eadbf5115aeb89cd65","topic":"作用：","expanded":true,"children":[{"id":"488a65e9714b4975e9d10a19a7","topic":"通过进程需求来提供设备","expanded":true}]},{"id":"e27a44a29afb5f4f0ed148d330","topic":"死锁：","expanded":true,"children":[{"id":"95694d7cc4f8268173d3a87fd2","topic":"有可能”死锁”","expanded":true}]}]}]},{"id":"6d9a57e7a6c97e2b6405eb8872","topic":"设备分配算法：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e4a890ce34cb8c653ffe38547d","topic":"先请求先分配","expanded":true,"style":{"background":"#8EDE99"}},{"id":"cb8b02ccac4a4f4e9a27baf808","topic":"优先级高优先","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"c54a8ab7302aedde771f3a448d","topic":"逻辑名到物理名的映射：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"b9c8e8c672e8336e8dda29b307","topic":"LUT：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"709baa68bcca4535a5b0ca4c29","topic":"名称：","expanded":true,"children":[{"id":"90bbd60e5b08959cdc5ffbfb75","topic":"逻辑设备表","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"af1b22f867687653cfbbd8055e","topic":"表项：","expanded":true,"children":[{"id":"bd9894b59909c8aec70fa9bcdc","topic":"逻辑设备名、物理设备名、驱动程序入口","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"57a836b5e17b876f30b1d81673","topic":"单用户：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"77381ab656e9e9008b66ebb3df","topic":"每个设备都在这个LUT中，不运行出现相同的逻辑设备名","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"0f3983d96a59e81fdf6f2b9288","topic":"多用户：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"7cbaf023a93bdc9f075d0875a5","topic":"每个用户在登录时，系统会给用户【创建一个进程和一个LUT】，这个LUT会放入到PCB中","expanded":true,"style":{"background":"#FDD834"}}]}]}]}]},{"id":"1b2a4e89fe3bdc1047adfb3882","topic":"SPOOLing技术","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-9e593d6b1135b0.svg"},"children":[{"id":"4a969a57-e697-47f9-869a-6bbf7c1c734e","topic":"体现操作系统：虚拟性","expanded":true},{"id":"65ca9108-8604-47f5-981b-e5e541c2cd83","topic":"SPOOLing和缓冲区的区别","expanded":true,"children":[{"id":"425ca82c-2e93-4e94-89e5-e226c94b4b93","topic":"CSDN","expanded":true,"hyperlink":"https://ask.csdn.net/questions/698957"},{"id":"1970c162-9573-4a2b-bc36-11aa2ad5ad55","topic":"缓冲区：","expanded":true,"children":[{"id":"226d7b3c-1846-4399-82c4-a4a6ea9c69be","topic":"为了能够尽快的利用分到的时间片资源，往往大家都是将任务写入buffer，然后等buffer满了在一次性提交任务。这样的批处理能够减少申请资源的次数","expanded":true}]},{"id":"6c8d7259-be29-43bc-b54d-bead23b9222f","topic":"SPOOLing：","expanded":true,"children":[{"id":"d117ce2d-c9ee-48d5-8bda-96cbb270a046","topic":"spooling技术本质上是添加了一个消息队列+异步执行+完成回调，可以让一个独占资源变成共享资源的一个功能","expanded":true}]}]},{"id":"6defbf37-b09d-4c1d-accf-a4f8ec2c4a63","topic":"用空间换时间的技术","expanded":true,"children":[{"id":"11cde93b-4591-4c46-8403-092b14310c01","topic":"vs 请求分页系统：时间换空间","expanded":true}]},{"id":"ee4af19332f9002d4ac83b5553","topic":"脱机技术：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"5cea55ec51396043f712784bb2","topic":"批处理阶段引入了脱机输入/输出技术（用磁带完成）","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ac3217dfd65f4d.png","width":580.57,"height":219.43}}]},{"id":"182a6942-ff97-4c28-8e3d-7526690b290f","topic":"SPOOLING技术","expanded":true,"children":[{"id":"a0e865c2-aa91-4150-b969-fe1f816b0d35","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-7ec1eec1507d1d.png","width":478.85,"height":289.83},"children":[{"id":"24089f26537aa69d64a98a1f8d","topic":"共享打印机：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"ec80ef27-8aad-42ba-8752-1ffb0dc7fc21","topic":"当系统同意其打印时：有用户（输出进程）开辟一个空闲磁盘区","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"f4f9727462cbd239dc4bd9d26f","topic":"步骤：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"7f6bd371dd2bc0d584525b7cb5","topic":"1. 输出进程在输出井中给用户进程分配一个空闲磁盘块","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"3c48e604792b5f8a693a69533d","topic":"2. 输出进程为用户进程申请一个空白的“用户请求分页表”，将用户的打印填入其中，再将表挂到请求打印队列上","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"d182b40c-5605-44ad-a5f4-160bc931fb3d","topic":"特点：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"ce3f3938-9b42-454c-9b92-7cf8345c59c3","topic":"提高了IO速度","expanded":true,"style":{"background":"#FDD834"}},{"id":"2504073b-6394-483c-8a89-cb8aa908a2fa","topic":"将独占设备改造为了共享设备","expanded":true,"style":{"background":"#FDD834"}},{"id":"b5c5ca38-2f9e-4e28-a70c-457b99f88c61","topic":"实现了虚拟设备功能","expanded":true,"style":{"background":"#FDD834"}}]}]}]},{"id":"4ad55f1b-753b-4735-9a43-529d1afa0795","topic":"SPOOLing的外围控制机","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"ac7c779d-28bc-4d7d-a25d-f1ad8b8cdc45","topic":"SPOOLing需要利用【专门的外围控制机】","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"4785ae50-0fc7-4a20-a638-7371decb0952","topic":"这里的外围控制机指使用软件模拟的外围控制机，而非物理上的","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"21168efd-d415-433a-b388-b128d4b79ff4","topic":"输入和输出进程来模拟外围控制机","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"f10c95cf-dc97-407f-b546-f1f110c4e3db","topic":"SPOOLing需要专门的【外存设备】","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"79976e15-0563-4e87-9c9e-71c415c8cbef","topic":"SPOOLing需要磁盘上的输入井和输出井","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"808be85c-18fe-461b-9ebd-c094f320bf71","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"0a72ae88-843c-46c1-8f06-807191d0cee4","topic":"09、11-13、15、16、20、22","expanded":true}]}]},{"id":"8e240f08-94b7-4c98-a2c1-b6c25dd48ca4","topic":"磁盘的结构","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-127eb26f8b6f75.svg"},"children":[{"id":"80f33463-55c0-4035-955e-c2f1dc83f98d","topic":"磁盘的概念","expanded":true,"children":[{"id":"4da3a1cc-6709-482a-b9c5-e065610acc27","topic":"磁道","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"404da2cd-01bb-40f1-b619-8f2f6f2a0d86","topic":"一个又一个的【同心圆】","expanded":true}]},{"id":"8e88aae4-52b8-44af-802b-d4c31ad8c41c","topic":"磁道间隙","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e7ffdad4-f86c-472f-8492-055d012f5e59","topic":"每两个同心圆之间的【间隙】","expanded":true}]},{"id":"b4c2573e-c87a-4929-8486-93ad5332f359","topic":"扇区","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"46f2acc4-a8de-44d7-92ed-e3911e480470","topic":"一个磁道可以分为若干个【扇区】","expanded":true},{"id":"070f7b60-69ec-4439-9af1-d3a3428fc7cd","topic":"又称：磁盘块（物理上）","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"8abfc589-0b5e-4fa6-ab05-cbd4eb70fdb0","topic":"扇区间隙","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"95ffd97c-5ab7-44b7-997a-6a8ef51c5be8","topic":"每两个扇区之间的间隙","expanded":true}]},{"id":"444ab841-f0cb-4d5d-aea4-1bc929cbffc8","topic":"柱面","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"06559b5a-f902-4ad7-a23f-a204393109f0","topic":"多个磁盘垂直叠在一起时，所有磁道组成的垂直面就是柱面","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-0726c6e00e39f4.png","width":395.71,"height":358.48}}]},{"id":"bcf1a4c2-11b0-4750-9073-307c443f37c7","topic":"块","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"40b13aae-7e08-487d-a1d3-c72329b58d3a","topic":"物理块","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"de6e2b32-8f5d-4adf-97d0-141284d5c2a7","topic":"扇区","expanded":true,"style":{"background":"#FDD834"}},{"id":"65a590c4-5574-4fe8-a5fe-84d59f29fe57","topic":"物理上读写一次的基本单位","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"b3ecd541-dd6b-4ed9-a0ac-97611b2a4ed2","topic":"逻辑块","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"2490e1b5-063d-4cab-9fe4-8c3b818bfbba","topic":"簇","expanded":true,"style":{"background":"#FDD834"}},{"id":"777d320d-807a-4e89-b52c-01feea93054b","topic":"OS中存储空间分配的最小单位","expanded":true,"style":{"background":"#FDD834"}}]}]},{"id":"987f8b02-4bff-4219-b978-76e4ad645f2d","topic":"磁盘地址形式：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"efc9f607-4fc3-4125-8541-c66deaf9f1b8","topic":"<柱面、盘面、扇区>","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"fa41df33-654d-41ca-86f9-c203e4f599b8","topic":"因为移动磁头是需要很多时间的","expanded":true}]}]}]},{"id":"735e5650-5c4c-4513-bb83-8af574aea0f5","topic":"磁盘的类型","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"274277d5-090f-46e1-9cb5-a5d5a1fce3b2","topic":"磁头","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"2f1bacde-5af0-4842-ace1-45c783b30039","topic":"固定头磁盘","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"c687b00a-818c-40c6-b264-de0219b94d3f","topic":"每个磁道一个磁头","expanded":true}]},{"id":"0f29e461-3e87-45b6-bc7a-67fadff41f8c","topic":"活动头磁盘","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"555c595a-8969-4b7b-8797-b35891afac88","topic":"每个磁盘一个磁头，磁头可以来回移动","expanded":true}]}]},{"id":"da55ba97-3b35-4885-84d3-a99b64b598b8","topic":"磁盘","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"853e7c5a-402e-4ef2-8ccb-7bffad35eac6","topic":"固定盘磁盘","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"f1765732-aa4c-4bce-8355-4a89da86e407","topic":"磁盘永久固定","expanded":true}]},{"id":"fd5b4949-b748-4080-b5fb-885b240eacc3","topic":"可换盘磁盘","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"5d1a2e0c-514a-4414-a192-696fa95a144f","topic":"磁盘可以移动和更换","expanded":true}]}]}]},{"id":"c9c1c6bc-7ea6-4ed8-b3f1-2f651722a950","topic":"存储介质","expanded":true,"children":[{"id":"037eb757-03ec-44b2-8036-caffb26e7e8b","topic":"可以随机存储的：","expanded":true,"children":[{"id":"3826d35c-8d33-4b5a-82c4-1ce22b548012","topic":"光盘","expanded":true},{"id":"1cdf1634-5cde-41ab-9c51-3e6560868c71","topic":"磁盘","expanded":true},{"id":"fc4aa098-3d51-482b-a663-646016f4693d","topic":"U盘","expanded":true}]},{"id":"156f16ef-26ce-4131-84e4-d56e8c14a388","topic":"只能顺序存储的：","expanded":true,"children":[{"id":"438e2322-4b54-4eed-9f03-df643ff7b368","topic":"磁带","expanded":true}]}]},{"id":"3601f8e3-2e43-4261-bd1c-b76d386defee","topic":"磁盘是共享设备","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"6b14ae52-c6a2-4704-901f-f0903dbfe1bd","topic":"但是同一时刻只有一个进程/作业可以启动磁盘","expanded":true,"style":{"background":"#FFABD5"}},{"id":"42ca5210-bba1-4bc7-bf90-eb5080cedd0b","topic":"此处和PV互斥有些不一样，例如读磁盘是多读者，那么对应过来多个进程可以在自己的运行时间内访问磁盘","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"9a5aea65-ac90-4323-b13f-552da041956a","topic":"而如果是写磁盘，那么PV信号量会控制其他正在处理机上的进程不能使用该磁盘","expanded":true,"style":{"background":"#FFABD5"}}]}]}]},{"id":"179a4141-ba4e-4c88-b655-77acb4ddf5ca","topic":"磁盘的管理","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-b909c9ea94bb18.svg"},"children":[{"id":"b81e8dbe-3d97-4e27-aa46-4c47d92230f3","topic":"磁盘初始化","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"e039e1c4-5626-48eb-89a0-879e900960b9","topic":"第一步：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"65d12ae3-6058-40b2-ba47-8e9c2ef321ff","topic":"名称：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"0934e26e-fb0d-4d91-8c5d-fd331c1c456a","topic":"低级格式化","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"66feb9a5-c958-4d3c-930a-d3200effe2be","topic":"分磁道、分扇区","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"a3bc0b48-3504-45d9-a553-d5b5a079a6f7","topic":"内容：","expanded":true,"children":[{"id":"e34f4a03-aaa6-4841-9d09-7b4e217ba67b","topic":"在出厂之前把磁盘的各个磁道分为扇区。","expanded":true}]},{"id":"acbcfa3e-8d36-44a0-a684-b592bd59adb2","topic":"每个扇区分为：","expanded":true,"children":[{"id":"4acbeda6-9fb6-405d-9996-68893590b219","topic":"数据区域","expanded":true},{"id":"f0f17389-cc9f-44da-843b-d2d7df5da10d","topic":"头、尾包含磁盘控制器\n所需要的信息例如：","expanded":true,"children":[{"id":"c8efc407-bb39-443e-83ea-6c6754efb3e5","topic":"数据结构","expanded":true},{"id":"cdcc087e-eacc-4060-b00d-e87c33191df6","topic":"扇区校验码","expanded":true}]}]}]},{"id":"f30b4ff4-6943-4032-8ab8-438f106faad0","topic":"第二步：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"64568738-33de-4286-b87e-a33c3d6c7125","topic":"做法：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"772a1840-28b6-47e3-92bb-6de64e6b17af","topic":"将磁盘分区，每个分区由若干柱面组成","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"2ce67983-af82-4cd5-99ba-1a37fc071c1b","topic":"分柱面","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"2e5371fd-73e5-4421-8378-2cdd8db14239","topic":"例如：","expanded":true,"children":[{"id":"e9101b5e-bbc9-483a-b80a-af3eda795c19","topic":"分为CDEF盘","expanded":true}]},{"id":"f2119ba0-adeb-49bb-adb5-3c2d0b6e7c62","topic":"物理地址：","expanded":true,"children":[{"id":"4c77e3bb-d76e-41c2-8848-c616d47e30c3","topic":"因为是<柱面、盘号、磁道号>","expanded":true}]}]},{"id":"44d8f52f-66e3-4a44-a565-8d1fe37ab70e","topic":"第三步：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"cea3b2b7-ba63-4311-85ec-ba2c0b379d69","topic":"名称：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"583f2d14-1270-4da8-a9e6-6843373760a8","topic":"逻辑格式化","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"b1799f29-6f87-465a-a2a5-2a8c90b7fb1c","topic":"创建文件系统","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"4be16670-8e97-4d45-a47f-770c1616b9e4","topic":"作用：","expanded":true,"children":[{"id":"37b160c1-4688-46c9-b0a9-f50ea9193311","topic":"创建文件系统","expanded":true,"children":[{"id":"49611760-70e0-452e-b244-c239ffc24131","topic":"根目录","expanded":true},{"id":"961b065d-001e-49c1-8093-2db9cd04313c","topic":"管理空闲磁盘块\n的数据结构，如：","expanded":true,"children":[{"id":"a26ed662-bcb7-46a6-bcaf-92f54df37492","topic":"位示图","expanded":true},{"id":"5cb64d68-c862-4f1b-b196-bd1542997fa8","topic":"空闲表","expanded":true},{"id":"864dccd7-529d-4336-b983-7a78524b6d07","topic":"空闲盘块链","expanded":true},{"id":"c1125248-180c-4a09-9407-9837c02b7972","topic":"空闲盘区链","expanded":true},{"id":"1fde8ea1-6d88-457d-9351-90d33b53ef81","topic":"超级块","expanded":true}]}]}]}]}]},{"id":"866a082e-3923-4eaa-8b59-a5af7960ec8f","topic":"引导块","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"6bf0939d-fd7e-4b8e-8fc1-05f3452e043b","topic":"概念：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"86324902-baa6-4221-9b87-66ead960afaa","topic":"计算机启动时会从引导块中读入一个初始化程序（自举程序）","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"d23a58ad-264c-40a4-9904-08e200003b05","topic":"初始化程序作用：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"f4305805-7e45-4638-82c0-12aaa871dd3c","topic":"初始化程序可以初始CPU、寄存器、设备控制器、内存etc，然后可以启动操作系统","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"35596421-307c-4a6f-b8bc-c0903a9decdf","topic":"自举程序存储位置：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"b45239a7-a8cf-4b1d-b2bd-a6fff8acbb13","topic":"【自举程序】存在ROM中\n 或：\n【自举装入程序】在ROM中，完整的自举程序在磁盘启动块（引导块）上，一般是在一个固定的位置","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"095a4a84-2701-409c-912b-3c60c36297cb","topic":"拓展","expanded":true,"children":[{"id":"5e57dea2-7563-4673-be5d-e594788860e2","topic":"引导控制块","expanded":true,"children":[{"id":"65a8602c-fd9d-4840-8046-2409409dd3b8","topic":"包含OS从该分区引导OS所需要的信息","expanded":true},{"id":"07891de3-305e-460c-b2a6-36122babc396","topic":"UFS中称为引导块，NTFS中称为分区引导扇区","expanded":true}]},{"id":"c6579792-6dc7-489a-98dc-0ac708f81959","topic":"分区控制块","expanded":true,"children":[{"id":"f5bcf14a-df53-4480-aefb-b6ff8e062166","topic":"包含分区信息（分区块数、块大小、空闲块情况）、空闲FCB数量、指针","expanded":true},{"id":"72c193e3-e4ec-48e9-91d4-37b8db211b65","topic":"UFS称为超级块、NTFS称为主控文件表","expanded":true}]}]}]},{"id":"a0d1e81a-9451-4ddb-8d3d-df97403a79a6","topic":"坏块","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"a32e469d-6910-4735-9c98-853a48b887fc","topic":"简单磁盘","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"71a2e647-2f05-4958-b909-9b2d53abde6c","topic":"在FAT中标明，程序不会使用它","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"36c14efc-d117-4fd5-a3fa-8433488b92e5","topic":"复杂磁盘","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"59622cf8-4ff1-439a-993c-141c006e7acd","topic":"磁盘控制器维护一个磁盘坏块链表，同时会有一些块用来作为备用（扇区备用）","expanded":true,"style":{"background":"#8EDDF9"}}]}]}]},{"id":"110279f6-19b4-4a9e-b203-bf6ad62c2560","topic":"磁盘调度算法","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-05bb20abd63104.svg"},"children":[{"id":"6ff6bf9f-921d-41c8-bbea-d5641bb38516","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"839ea0b6-46d3-4c42-b603-c02ee5539571","topic":"09、15、17*2、18、21、10大、19大、21大","expanded":true}]},{"id":"f6847a58-1d27-42d9-a9dd-feb67d985e3b","topic":"图示+公式：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"02d5ab0c-4f6a-477b-b803-421a8fb5b739","topic":"1. 启动时间  2. 寻找/寻道时间  3. 旋转【延迟】时间  4. 传输时间","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-39c9edd55a153c.png","width":645.46,"height":388.38}}]},{"id":"f8e8826d-7e8f-4800-bb5a-78b945502004","topic":"可以优化的","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"96095680-52b3-4f8d-a792-bea404bbf760","topic":"延迟时间","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"4e6346af-a914-4f26-bebb-613d145d4c30","topic":"平均：","expanded":true,"children":[{"id":"128c7ef5-f7c8-4731-bf7b-fadec5a1ef48","topic":"1/2r","expanded":true}]},{"id":"091d7e4b-6c10-49fd-9063-24035b36c8e7","topic":"有关：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"094e3654-1483-490f-811d-30d358ad7173","topic":"磁盘空闲空间分配程序","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"b1f9f91b-8437-408f-9839-2eb6a5410ba2","topic":"是否错位编号","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"f6b38175-06a0-4924-ad9b-031a1ea80c9d","topic":"程序规定的分配方式是直接分配相邻块（每次读取的旋转时延为一整圈）","expanded":true,"style":{"background":"#FF9595"}},{"id":"27538cc5-6547-4bdd-a69c-ccad09770d2e","topic":"若是相邻一个分配（每次读取的旋转时延为一个簇）","expanded":true,"style":{"background":"#FF9595"}}]}]},{"id":"17eff9a6-783d-45d8-90e5-ef9c45cb80f7","topic":"物理结构","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"743e9bc0-fc61-4011-b5d1-4bf995f92020","topic":"是连续分配还是链接分配","expanded":true,"style":{"background":"#FFABD5"}},{"id":"704fcfa2-3580-41df-b775-d9d4d8e4c170","topic":"连续分配：可以只转圈","expanded":true},{"id":"0ae5742b-c628-4f97-8528-2014d6b0cb5f","topic":"链接分配：可能需要换柱换盘块","expanded":true}]}]},{"id":"23f4b67d-3ba4-418e-8fa3-0ee4701adf91","topic":"数据处理时间的影响：","expanded":true,"children":[{"id":"8ee44c67-c27e-47f3-aea2-7e9359516acb","topic":"会影响间隙大小，其实影响不大","expanded":true}]}]},{"id":"ba7b1621-8375-4377-a612-309b4e08e20c","topic":"寻道时间","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"8be0495e-2279-4135-833c-49667d1a35da","topic":"有关：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"65614858-fdd3-4cf7-835d-7bfb0c31f0af","topic":"磁盘调度算法","expanded":true,"style":{"background":"#FFABD5"}}]}]}]},{"id":"392c13a5-25b7-47f0-acd8-4d5feb6ff662","topic":"调度算法","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"6c066949-9c5e-42bf-8007-0f89aec010fb","topic":"FCFS算法","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"a266cc09-78e2-407c-bb31-3fc3df27e347","topic":"根据进程请求访问磁盘的先后顺序进行调度","expanded":true,"style":{"background":"#FDD834"}},{"id":"b85007d6-0939-4c4c-85f2-af1002dbc592","topic":"优点","expanded":true,"children":[{"id":"5b687fad-b195-452e-92ac-fe861125b381","topic":"公平、简单","expanded":true}]},{"id":"415f8b90-369d-41ad-946c-adc4b058618b","topic":"缺点","expanded":true,"children":[{"id":"98d84c06-5058-4ab6-aeb3-20ba5824b87c","topic":"平均寻道距离大，I/O较少可以使用","expanded":true}]}]},{"id":"9b6617bf-91b7-4ac6-a144-d0e61277378c","topic":"SSTF算法","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"0c387b6c-3bc5-453e-950d-ba92c0c4f0a2","topic":"调度处理的磁道是与当前磁头所在磁道距离最近的磁道","expanded":true,"style":{"background":"#FDD834"}},{"id":"79846687-570e-4445-a628-180af61280e5","topic":"优点","expanded":true,"children":[{"id":"89da89b0-b16b-485e-8abc-e5aebb96c893","topic":"性能比FCFS好（贪心算法）","expanded":true}]},{"id":"fbe15800-d7a8-408f-b2ca-0b0ff65f4d5e","topic":"缺点","expanded":true,"children":[{"id":"2d4374f0-20b6-44ad-b694-f2868e50be74","topic":"可能出现“饥饿”现象","expanded":true}]}]},{"id":"31475d43-cff5-4838-aedf-ea7aacf767ce","topic":"SCAN算法","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"bc3b3f00-a190-4e44-80fd-b225eee98932","topic":"（电梯调度算法）","expanded":true},{"id":"8196205c-d457-4e74-a731-13212aab5839","topic":"磁头【当前移动方向】上选择与当前磁头所在磁道距离最近的请求作为下一次服务的对象","expanded":true,"style":{"background":"#FDD834"}},{"id":"f3098dcf-9b62-4f54-a7ed-faf8c3607caf","topic":"优点","expanded":true,"children":[{"id":"ed4f846f-1c63-49d6-beb5-d14042c7ffd1","topic":"性能好，不会有“饥饿”","expanded":true}]},{"id":"6cc2499c-73ec-41fc-9834-b32d80995534","topic":"缺点","expanded":true,"children":[{"id":"d34a7648-4a21-4cfa-b73c-bc5b7a37d48f","topic":"不利于远离磁头一端的访问","expanded":true}]},{"id":"9f8f64d7-b571-459f-843b-444b45f05c2c","topic":"LOOK调度","expanded":true,"children":[{"id":"461b62d5-66d8-4c1e-95c2-24c382518627","topic":"不用扫到两端，扫到最左/最右的磁盘请求就行","expanded":true}]}]},{"id":"af51976e-c5c8-4747-bc67-b862affcc446","topic":"C-SCAN算法","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"7b6572a9-bbeb-4783-b1ee-48124803891d","topic":"回返时直接快速移动至起始端而不服务任何请求","expanded":true,"style":{"background":"#FDD834"}},{"id":"154fe42f-0bd8-419b-85af-ab026e578881","topic":"优点","expanded":true,"children":[{"id":"397d3aac-3cdd-46de-8a24-44354dbb7e74","topic":"磁道请求公平","expanded":true}]},{"id":"d9ff43ab-f8c7-4693-b27a-46b17acb70ac","topic":"C-LOOK调度","expanded":true,"children":[{"id":"50c02e08-459d-48d6-942d-cff9dc00435b","topic":"同理","expanded":true}]}]},{"id":"6baa0e33-f389-47b4-98a2-b85782eeaab1","topic":"磁臂黏着","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"794276d5-7b80-42c2-ab0d-eb1cd8260e3f","topic":"只有FCFS没有，如果在算法访问某个磁道时，这个磁道又进行了请求，就会一直被访问","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"57bd16cc-2671-4293-bb23-2007aabb582a","topic":"很诡异，记住就行","expanded":true}]}]}]},{"id":"7d94871b-913b-4f04-afb6-edd76857a915","topic":"错位编号","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"1a0e9ca4-df18-4b5e-865b-a3a87e7bf417","topic":"同一盘面","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"40cea28d-5d9f-4e6a-95a7-38c3726e16d9","topic":"同一盘面，物理地址相邻的扇区，在磁盘中应交错存放（留一些处理时间给磁头）","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"9c1005cf-e067-436b-a443-92a53d784f4d","topic":"不同盘面","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"9803ba44-eb47-428b-8c98-bb8a6a1ce77e","topic":"同柱面不同盘面的扇区错位编号，可以缩短连续读写两个相邻盘面的时间","expanded":true,"style":{"background":"#FF9595"}}]}]}]},{"id":"9dfc5982-ed71-4adb-8057-ec8f88025243","topic":"固态硬盘SSD","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-640feabdb028d5.svg","width":80.39,"height":81.72},"children":[{"id":"63ee90bd-6a38-4971-8ade-7305162a1c84","topic":"基于闪存的存储器","expanded":true,"children":[{"id":"cf6cb678-46e9-4f70-a924-05f79829796b","topic":"存储介质：NAND颗粒","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"0a1da727-533e-4596-8885-d06f8a0a34f1","topic":"读写速度比较：","expanded":true,"children":[{"id":"06390056-f2fa-405f-a8f2-6b230f69a478","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-587b202b3b391d.png","width":720.53,"height":297.85},"children":[{"id":"8e244fde-d96a-4469-a194-09094270cf19","topic":"（硬件茶谈）","expanded":true}]}]},{"id":"82602153-7b82-46a0-8436-c8d80343543b","topic":"组成：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"22c1d3d0-c437-49e5-8fe7-8820c2c7c7e0","topic":"闪存翻译层 + 多个闪存芯片","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-31ca5ac5ea8a23.png","width":543.71,"height":321.43},"children":[{"id":"00ef815c-35cf-44b4-b8be-5e37e8715c35","topic":"读写单位","expanded":true,"children":[{"id":"c0e9a5c0-53dc-43f8-9f33-0720e4ef46a4","topic":"CPU下令要读取一个块的内容","expanded":true},{"id":"2cffbf74-50e9-4b52-8c52-0c55730676ac","topic":"SSD的读取单位：一个页","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"e7e26ca0-ee5a-4132-aea9-5ada13a941ce","topic":"SSD接受到这个块的地址","expanded":true},{"id":"c1aee4a9-8967-4e62-8915-46fb38620d17","topic":"SSD的闪存翻译层把它翻译为SSD中对应的数个页的地址","expanded":true},{"id":"09fdc5ee-c827-406e-9333-de36680f92a2","topic":"SSD把这些页的数据发到IO总线上，返回CPU","expanded":true}]},{"id":"96c3dec3-1437-4e7e-a561-f4d3645c6104","topic":"具体大小：机械磁盘的一个块大小可能在1KB；SSD的一个页大小是512B~4KB，一个块中有32~128个页","expanded":true,"style":{"background":"#8EDE99"}}]}]}]},{"id":"cf2369e7-dd58-4502-8be5-2e15c6086675","topic":"读写原则：","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"adc33221-f646-427e-ba1b-25e4f6a9e6d4","topic":"读：以一个页为单位来读 ✅","expanded":true,"style":{"background":"#FF9595"}},{"id":"43f6e780-77a2-4903-b319-4be79a8f98d2","topic":"写：以一个页为单位来写","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"89df4543-cfd0-46e5-8517-cedc05a9d26c","topic":"擦除：以一个块的单位来擦除","expanded":true},{"id":"e8659d30-8c2b-4f29-adb0-41001dbbbdfe","topic":"擦除方法：先把要写那页的整块复制到另一块，然后再擦除原来那块","expanded":true,"children":[{"id":"422905e3-c7e8-4efc-9935-185f26b19d3d","topic":"复制过后，在闪存翻译层中会建立新的： ‘逻辑地址’ —— ‘物理地址’ 的转换关系","expanded":true}]},{"id":"26817d0c-a6db-4c14-aaf9-a06264f1aa0f","topic":"擦除的缺点：","expanded":true,"children":[{"id":"e5731d80-d9e0-4442-a5b0-c84645bf8897","topic":"擦除多了会造成磨损","expanded":true}]}]}]},{"id":"95d954a5-1c83-4132-8368-9d0fc35bf722","topic":"平均磨损","expanded":true,"children":[{"id":"4cb781e0-0e11-4194-a174-fd1081dd0f1a","topic":"静态平均：","expanded":true,"children":[{"id":"f47ab9e3-4dee-433e-9925-9d5ef7d3c15d","topic":"SSD在进行擦除后的数据迁移的时候，会让寿命比较老的闪存块担任“读”的责任，让新的闪存块担任“写”的责任","expanded":true}]},{"id":"5bd133b4-4172-4b05-aa6d-7121a3c95f3d","topic":"动态平均：","expanded":true,"children":[{"id":"a7e4af31-bec6-446e-925b-b9450664c6ac","topic":"在SSD写入新数据的时候，会优先选择磨损次数少的块进行写入","expanded":true}]}]},{"id":"edc7c097-179a-488e-94a8-65c4af8d2ef1","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"585eb8d4-fae8-40be-b725-dac4369f3ac5","topic":"无","expanded":true}]}]},{"id":"3bd95fe83a5ac3450b7c3a3bc8","topic":"END","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c2539473d179e5.svg"}}]},"relations":[{"id":"a91313e6-e535-4ffc-8b0f-1902a777db81","from":"eb68a188dcf9164a87cfdac332","to":"694897136dd86209129f08ecda","bidirectional":false},{"id":"6152572a-b23d-4e9a-8481-811a567f8110","from":"ecf05c35-d25e-4290-8e2f-942bd26a7d05","to":"f87ee7a8-0246-43d5-9b97-d244d1013ed1","bidirectional":false},{"id":"51598d91-b867-4b44-8df6-bef3ceec5097","from":"ba7b1621-8375-4377-a612-309b4e08e20c","to":"392c13a5-25b7-47f0-acd8-4d5feb6ff662","bidirectional":false},{"id":"f8b43d78-289b-4bfb-8f39-ce158c0e5d88","from":"c0e9a5c0-53dc-43f8-9f33-0720e4ef46a4","to":"2cffbf74-50e9-4b52-8c52-0c55730676ac","bidirectional":false,"label":"闪存翻译层"}],"summaries":[{"id":"85bdd685-1ebb-45c7-88a3-b3595b9c0aa6","parentId":"4ebabf1166298a106fbeaac505","start":0,"end":3,"label":"【数据寄存器】\n【控制寄存器】\n【状态寄存器】\n【地址线】\n【控制线】"},{"id":"97fc62a4-a766-4013-a085-e974f19df12a","parentId":"b4722863-e7a9-4530-b753-77792548f41f","start":0,"end":4,"label":""},{"id":"a9257bb4-e63e-457d-8710-5ae90d612a77","parentId":"056aab5c56aa3a2977c2c93354","start":0,"end":2,"label":"总时间：max(T, C) + M"},{"id":"cf050910-7b43-433c-bce5-ed71cada7165","parentId":"054260f1-038f-4135-bd8c-3ed3548f5ed1","start":0,"end":2,"label":"总时间：max(T, M+C)"},{"id":"2d4b1783-abed-4a84-9cd0-b8dd7aec15d8","parentId":"529b8fb845296efa501e8b1f3d","start":3,"end":4,"label":"指向正在等待该控制器的【进程队列】"},{"id":"8302ccd0-bf28-4699-baba-fb0bf12e180c","parentId":"8fc830a1ce499dc9a9e2d9a319","start":3,"end":3,"label":""},{"id":"e7352edd-e086-4c3e-b057-212e5cec3ef7","parentId":"80f33463-55c0-4035-955e-c2f1dc83f98d","start":0,"end":3,"label":""},{"id":"0d1103c2-a01f-4a86-990a-3088795e0345","parentId":"037eb757-03ec-44b2-8036-caffb26e7e8b","start":0,"end":1,"label":"存储原理类似，一个用磁性物质存，一个用光学物质存"},{"id":"eba62e36-eacb-41d5-abb6-2295b6c363a0","parentId":"392c13a5-25b7-47f0-acd8-4d5feb6ff662","start":2,"end":3,"label":"若无特殊说明，默认采用LOOK而不是SCAN（C-LOOK / C-SCAN）"},{"id":"367ac7b2-b215-4c62-b5a6-666c384b3db5","parentId":"95d954a5-1c83-4132-8368-9d0fc35bf722","start":0,"end":0,"label":"静态平均的效果比动态平均效果更好"}],"boundaries":[{"id":"eea9fe5b630986243bf058c142","parentId":"40fa0fc48949c07e0324d97904","start":3,"end":5,"label":"I/O子系统"},{"id":"b713e7d1-969f-4fd6-8264-816547176719","parentId":"40fa0fc48949c07e0324d97904","start":4,"end":5,"label":"直接处理硬件","style":{"stroke":"#BA69C8"}}]}}}]}}