[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"site-config":3,"primary-menu":6,"cat-os":85,"catposts-os":99,"post-detail-post-os-deadlock-f7833246":208},{"config":4,"socialLinks":5},null,[],{"metadata":7,"spec":10,"menuItems":20},{"name":8,"creationTimestamp":9},"primary","2026-09-12T06:13:55.024154Z",{"displayName":11,"menuItems":12},"主菜单",[13,14,15,16,17,18,19],"88c3f10b-321c-4092-86a8-70db00251b74","menu-item-izrtmxer","c4c814d1-0c2c-456b-8c96-4864965fee94","menu-item-column","menu-item-tools","menu-item-zsxq","menu-item-ocrxlczu",[21,30,40,49,58,67,76],{"displayName":22,"metadata":23,"spec":25,"status":28,"children":29},"首页",{"name":13,"creationTimestamp":24},"2026-09-12T06:13:54.422830Z",{"displayName":22,"href":26,"priority":27,"menuName":8},"\u002F",0,{"displayName":22,"href":26},[],{"displayName":31,"metadata":32,"spec":34,"status":38,"children":39},"Java面试八股",{"name":14,"creationTimestamp":33},"2026-09-13T09:42:02.854891Z",{"displayName":31,"href":35,"target":36,"priority":37,"menuName":8},"\u002Fjava-interview","_self",1,{"displayName":31,"href":35},[],{"displayName":41,"metadata":42,"spec":44,"status":47,"children":48},"文章",{"name":15,"creationTimestamp":43},"2026-09-12T06:13:54.457307Z",{"displayName":41,"href":45,"priority":46,"menuName":8},"\u002Farchives",2,{"displayName":41,"href":45},[],{"displayName":50,"metadata":51,"spec":53,"status":56,"children":57},"项目实战",{"name":16,"creationTimestamp":52},"2026-09-14T00:35:08.138170Z",{"displayName":50,"href":54,"target":36,"priority":55,"menuName":8},"\u002Fcolumn",3,{"displayName":50,"href":54},[],{"displayName":59,"metadata":60,"spec":62,"status":65,"children":66},"在线工具",{"name":17,"creationTimestamp":61},"2026-09-14T00:35:08.171474Z",{"displayName":59,"href":63,"target":36,"priority":64,"menuName":8},"\u002Ftools",4,{"displayName":59,"href":63},[],{"displayName":68,"metadata":69,"spec":71,"status":74,"children":75},"知识星球",{"name":18,"creationTimestamp":70},"2026-09-14T00:35:08.199145Z",{"displayName":68,"href":72,"target":36,"priority":73,"menuName":8},"\u002Fzsxq",5,{"displayName":68,"href":72},[],{"displayName":77,"metadata":78,"spec":80,"status":83,"children":84},"特价云服务器",{"name":19,"creationTimestamp":79},"2026-09-25T15:30:59.201614Z",{"displayName":77,"href":81,"target":36,"priority":82,"menuName":8},"\u002Fserver",6,{"displayName":77,"href":81},[],{"metadata":86,"spec":91,"status":97,"postCount":73},{"name":87,"creationTimestamp":88,"labels":89},"os","2026-09-13T09:13:25.893081Z",{"haloweb.section":90},"interview",{"displayName":92,"slug":87,"cover":93,"description":94,"priority":95,"hideFromList":96,"preventParentPostCascadeQuery":96},"操作系统面试题","","操作系统面试题：进程与线程、内存管理、IO 模型、CPU 调度与同步原语。",15,false,{"permalink":98,"postCount":73,"visiblePostCount":73},"\u002Fcategories\u002Fos",[100,124,145,166,187],{"metadata":101,"spec":104,"status":113,"categories":118},{"name":102,"creationTimestamp":103},"post-os-io-multiplexing-5e8493ea","2026-09-13T10:01:07.249312Z",{"title":105,"slug":106,"cover":93,"excerpt":107,"publishTime":109,"categories":110,"tags":111,"priority":27,"pinned":96,"deleted":96,"visible":112,"allowComment":108},"什么是 I\u002FO 多路复用？","os-io-multiplexing",{"raw":93,"autoGenerate":108},true,"2026-09-13T10:01:07.426950Z",[87],[],"PUBLIC",{"permalink":114,"excerpt":115,"lastModifyTime":116,"phase":117},"\u002Farchives\u002Fos-io-multiplexing","一、定义 单个线程通过系统调用同时监听多个文件描述符，哪个就绪就处理哪个，避免阻塞在单个 I\u002FO 上。 二、select select(maxfd, &readfds, &writefds, &exceptfds, &timeout);\n 位图存储 fd，有最大数量限制（1024）。 每次调用都要把","2026-09-16T09:15:12.821909Z","PUBLISHED",[119],{"metadata":120,"spec":122,"status":123,"postCount":73},{"name":87,"creationTimestamp":88,"labels":121},{"haloweb.section":90},{"displayName":92,"slug":87,"cover":93,"description":94,"priority":95,"hideFromList":96,"preventParentPostCascadeQuery":96},{"permalink":98,"postCount":73,"visiblePostCount":73},{"metadata":125,"spec":128,"status":135,"categories":139},{"name":126,"creationTimestamp":127},"post-os-memory-manage-c9ef3f72","2026-09-13T10:01:07.077926Z",{"title":129,"slug":130,"cover":93,"excerpt":131,"publishTime":132,"categories":133,"tags":134,"priority":27,"pinned":96,"deleted":96,"visible":112,"allowComment":108},"操作系统的内存管理？","os-memory-manage",{"raw":93,"autoGenerate":108},"2026-09-13T10:01:07.126511Z",[87],[],{"permalink":136,"excerpt":137,"lastModifyTime":138,"phase":117},"\u002Farchives\u002Fos-memory-manage","一、虚拟内存 每个进程有独立虚拟地址空间，通过页表映射到物理内存。进程以为自己独占内存。 二、分页 内存分成固定大小的页（通常 4KB），虚拟页映射到物理页帧。 页表：记录虚拟页到物理页的映射。 TLB：页表缓存，加速地址翻译。 缺页中断：访问的页不在内存，从磁盘加载。 三、分段 按逻辑单位分段（代","2026-09-16T09:15:12.350048Z",[140],{"metadata":141,"spec":143,"status":144,"postCount":73},{"name":87,"creationTimestamp":88,"labels":142},{"haloweb.section":90},{"displayName":92,"slug":87,"cover":93,"description":94,"priority":95,"hideFromList":96,"preventParentPostCascadeQuery":96},{"permalink":98,"postCount":73,"visiblePostCount":73},{"metadata":146,"spec":149,"status":156,"categories":160},{"name":147,"creationTimestamp":148},"post-os-deadlock-f7833246","2026-09-13T10:01:06.879036Z",{"title":150,"slug":151,"cover":93,"excerpt":152,"publishTime":153,"categories":154,"tags":155,"priority":27,"pinned":96,"deleted":96,"visible":112,"allowComment":108},"什么是死锁？如何避免？","os-deadlock",{"raw":93,"autoGenerate":108},"2026-09-13T10:01:06.930093Z",[87],[],{"permalink":157,"excerpt":158,"lastModifyTime":159,"phase":117},"\u002Farchives\u002Fos-deadlock","一、四个必要条件 互斥：资源同一时间只能被一个进程使用。 持有并等待：进程持有资源同时等待其他资源。 不可剥夺：已获得的资源不能被强制夺走。 循环等待：进程间形成循环等待链。 二、预防 破坏四个条件之一： - 破坏互斥：难（有些资源必须互斥）。 - 破坏持有并等待：一次性申请所有资源。 - 破坏不可","2026-09-16T09:15:11.876156Z",[161],{"metadata":162,"spec":164,"status":165,"postCount":73},{"name":87,"creationTimestamp":88,"labels":163},{"haloweb.section":90},{"displayName":92,"slug":87,"cover":93,"description":94,"priority":95,"hideFromList":96,"preventParentPostCascadeQuery":96},{"permalink":98,"postCount":73,"visiblePostCount":73},{"metadata":167,"spec":170,"status":177,"categories":181},{"name":168,"creationTimestamp":169},"post-os-scheduler-be6008d8","2026-09-13T10:01:06.684412Z",{"title":171,"slug":172,"cover":93,"excerpt":173,"publishTime":174,"categories":175,"tags":176,"priority":27,"pinned":96,"deleted":96,"visible":112,"allowComment":108},"进程调度算法有哪些？","os-scheduler",{"raw":93,"autoGenerate":108},"2026-09-13T10:01:06.733759Z",[87],[],{"permalink":178,"excerpt":179,"lastModifyTime":180,"phase":117},"\u002Farchives\u002Fos-scheduler","一、先来先服务（FCFS） 按到达顺序执行，非抢占。简单但短作业可能等待很久。 二、短作业优先（SJF） 预估运行时间短的先执行。平均等待时间最短，但长作业可能饥饿。 三、时间片轮转（RR） 每个进程分配一个时间片，用完就切换。适合交互式系统，响应快。 四、优先级调度 高优先级进程先执行。可抢占或非","2026-09-16T09:15:11.437318Z",[182],{"metadata":183,"spec":185,"status":186,"postCount":73},{"name":87,"creationTimestamp":88,"labels":184},{"haloweb.section":90},{"displayName":92,"slug":87,"cover":93,"description":94,"priority":95,"hideFromList":96,"preventParentPostCascadeQuery":96},{"permalink":98,"postCount":73,"visiblePostCount":73},{"metadata":188,"spec":191,"status":198,"categories":202},{"name":189,"creationTimestamp":190},"post-os-process-thread-afd2f460","2026-09-13T10:01:06.383471Z",{"title":192,"slug":193,"cover":93,"excerpt":194,"publishTime":195,"categories":196,"tags":197,"priority":27,"pinned":96,"deleted":96,"visible":112,"allowComment":108},"进程和线程的区别？","os-process-thread",{"raw":93,"autoGenerate":108},"2026-09-13T10:01:06.551909Z",[87],[],{"permalink":199,"excerpt":200,"lastModifyTime":201,"phase":117},"\u002Farchives\u002Fos-process-thread","一、定义 进程：程序运行的实例，资源分配的基本单位，有独立地址空间。 线程：进程内的执行单元，CPU 调度的基本单位，共享进程资源。 二、对比 维度 进程 线程 资源 独立地址空间 共享进程资源 切换开销 大（切换页表、TLB） 小 通信 IPC（管道、消息队列、共享内存） 共享内存（需同步） 健壮","2026-09-16T09:14:46.493415Z",[203],{"metadata":204,"spec":206,"status":207,"postCount":73},{"name":87,"creationTimestamp":88,"labels":205},{"haloweb.section":90},{"displayName":92,"slug":87,"cover":93,"description":94,"priority":95,"hideFromList":96,"preventParentPostCascadeQuery":96},{"permalink":98,"postCount":73,"visiblePostCount":73},{"metadata":209,"spec":210,"status":214,"categories":215,"content":221},{"name":147,"creationTimestamp":148},{"title":150,"slug":151,"cover":93,"excerpt":211,"publishTime":153,"categories":212,"tags":213,"priority":27,"pinned":96,"deleted":96,"visible":112,"allowComment":108},{"raw":93,"autoGenerate":108},[87],[],{"permalink":157,"excerpt":158,"lastModifyTime":159,"phase":117},[216],{"metadata":217,"spec":219,"status":220,"postCount":73},{"name":87,"creationTimestamp":88,"labels":218},{"haloweb.section":90},{"displayName":92,"slug":87,"cover":93,"description":94,"priority":95,"hideFromList":96,"preventParentPostCascadeQuery":96},{"permalink":98,"postCount":73,"visiblePostCount":73},{"content":222,"raw":222},"\u003Ch2>一、四个必要条件\u003C\u002Fh2>\n\u003Col>\n\u003Cli>\u003Cstrong>互斥\u003C\u002Fstrong>：资源同一时间只能被一个进程使用。\u003C\u002Fli>\n\u003Cli>\u003Cstrong>持有并等待\u003C\u002Fstrong>：进程持有资源同时等待其他资源。\u003C\u002Fli>\n\u003Cli>\u003Cstrong>不可剥夺\u003C\u002Fstrong>：已获得的资源不能被强制夺走。\u003C\u002Fli>\n\u003Cli>\u003Cstrong>循环等待\u003C\u002Fstrong>：进程间形成循环等待链。\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Ch2>二、预防\u003C\u002Fh2>\n\u003Cp>破坏四个条件之一：\n- 破坏互斥：难（有些资源必须互斥）。\n- 破坏持有并等待：一次性申请所有资源。\n- 破坏不可剥夺：可抢占。\n- 破坏循环等待：资源有序分配。\u003C\u002Fp>\n\u003Ch2>三、避免\u003C\u002Fh2>\n\u003Cp>银行家算法：分配资源前判断是否会导致系统进入不安全状态。\u003C\u002Fp>\n\u003Ch2>四、检测与解除\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>用资源分配图检测死锁。\u003C\u002Fli>\n\u003Cli>解除：终止进程、抢占资源。\u003C\u002Fli>\n\u003C\u002Ful>"]