This commit is contained in:
ridethepig 2023-04-10 21:11:08 +08:00
parent c64c66c73f
commit e698da3c30
7 changed files with 71246 additions and 26 deletions

View File

@ -4380,4 +4380,4 @@
:page 306}, :page 306},
:content {:text "cheapskate"}, :content {:text "cheapskate"},
:properties {:color "green"}}], :properties {:color "green"}}],
:extra {:page 309}} :extra {:page 311}}

View File

@ -0,0 +1,490 @@
{:highlights [{:id #uuid "6433ca28-1bdf-433d-8ed9-0d54bf5ba940",
:page 311,
:position {:bounding {:x1 199.265625,
:y1 543.921875,
:x2 243.2843017578125,
:y2 563.921875,
:width 719.9999999999999,
:height 1080},
:rects ({:x1 199.265625,
:y1 543.921875,
:x2 243.2843017578125,
:y2 563.921875,
:width 719.9999999999999,
:height 1080}),
:page 311},
:content {:text "thread"},
:properties {:color "yellow"}}
{:id #uuid "6433cb56-fbef-46da-83c2-13fa2dba2967",
:page 311,
:position {:bounding {:x1 577.609375,
:y1 1234.609375,
:x2 804.0300903320312,
:y2 1264.609375,
:width 1094.3999999999999,
:height 1641.6},
:rects ({:x1 577.609375,
:y1 1234.609375,
:x2 804.0300903320312,
:y2 1264.609375,
:width 1094.3999999999999,
:height 1641.6}),
:page 311},
:content {:text "thread control blocks"},
:properties {:color "yellow"}}
{:id #uuid "6433cb70-d168-4863-8268-1e969df6ce06",
:page 311,
:position {:bounding {:x1 274.29595947265625,
:y1 1133.640625,
:x2 422.473388671875,
:y2 1163.640625,
:width 1094.3999999999999,
:height 1641.6},
:rects ({:x1 274.296875,
:y1 1133.640625,
:x2 422.473388671875,
:y2 1163.640625,
:width 1094.3999999999999,
:height 1641.6}
{:x1 274.29595947265625,
:y1 1135.125,
:x2 274.3037109375,
:y2 1158.125,
:width 1094.3999999999999,
:height 1641.6}),
:page 311},
:content {:text "context switch"},
:properties {:color "yellow"}}
{:id #uuid "6433cba2-61bd-4549-a29f-2ad85b3e30cd",
:page 312,
:position {:bounding {:x1 480.51898193359375,
:y1 1039.890625,
:x2 683.934814453125,
:y2 1069.890625,
:width 1094.3999999999999,
:height 1641.6},
:rects ({:x1 480.53125,
:y1 1039.890625,
:x2 610.921875,
:y2 1069.890625,
:width 1094.3999999999999,
:height 1641.6}
{:x1 480.51898193359375,
:y1 1041.375,
:x2 683.934814453125,
:y2 1064.375,
:width 1094.3999999999999,
:height 1641.6}),
:page 312},
:content {:text "thread-local storage,"},
:properties {:color "yellow"}}
{:id #uuid "6433e4cc-69e4-4057-8cc6-1766240d82f4",
:page 320,
:position {:bounding {:x1 554.1071472167969,
:y1 682.4375152587891,
:x2 670.6859741210938,
:y2 705.8660888671875,
:width 864,
:height 1296},
:rects ({:x1 554.1071472167969,
:y1 682.4375152587891,
:x2 670.6859741210938,
:y2 705.8660888671875,
:width 864,
:height 1296}),
:page 320},
:content {:text "race condition"},
:properties {:color "yellow"}}
{:id #uuid "6433e52b-1f38-4f7c-b168-0aed624f9bdf",
:page 320,
:position {:bounding {:x1 0,
:y1 509.14286518096924,
:x2 746.7916259765625,
:y2 922.9732360839844,
:width 864,
:height 1296},
:rects ({:x1 0,
:y1 509.14286518096924,
:x2 0,
:y2 530.2857236862183,
:width 864,
:height 1296}
{:x1 0,
:y1 525.142865896225,
:x2 0,
:y2 546.285724401474,
:width 864,
:height 1296}
{:x1 515.8003540039062,
:y1 865.4107360839844,
:x2 746.7916259765625,
:y2 883.1250305175781,
:width 864,
:height 1296}
{:x1 171.89286041259766,
:y1 885.3303833007812,
:x2 745.5325088500977,
:y2 903.2589416503906,
:width 864,
:height 1296}
{:x1 171.89286041259766,
:y1 905.2589416503906,
:x2 682.6857986450195,
:y2 922.9732360839844,
:width 864,
:height 1296}),
:page 320},
:content {:text "A critical section is a piece of code that accesses a shared variable (or more generally, a shared resource) and must not be concurrently executed by more than one thread."},
:properties {:color "yellow"}}
{:id #uuid "6433e566-e6ef-45b3-84b1-eba981be914a",
:page 320,
:position {:bounding {:x1 0,
:y1 557.1428680419922,
:x2 752.232177734375,
:y2 984.7500305175781,
:width 864,
:height 1296},
:rects ({:x1 0,
:y1 557.1428680419922,
:x2 0,
:y2 578.2857246398926,
:width 864,
:height 1296}
{:x1 0,
:y1 573.1428680419922,
:x2 0,
:y2 594.2857284545898,
:width 864,
:height 1296}
{:x1 601.2857360839844,
:y1 925.5268249511719,
:x2 743.2662353515625,
:y2 948.9553833007812,
:width 864,
:height 1296}
{:x1 743.2589721679688,
:y1 927.1875305175781,
:x2 752.232177734375,
:y2 945.1160888671875,
:width 864,
:height 1296}
{:x1 171.89286041259766,
:y1 947.107177734375,
:x2 745.5417861938477,
:y2 965.0357360839844,
:width 864,
:height 1296}
{:x1 171.89286041259766,
:y1 967.0357360839844,
:x2 576.7512893676758,
:y2 984.7500305175781,
:width 864,
:height 1296}),
:page 320},
:content {:text "mutual exclusion. This property guarantees that if one thread is executing within the critical section, the others will be prevented from doing so."},
:properties {:color "yellow"}}
{:id #uuid "6433e6a1-407c-4936-b184-dee868ef4107",
:page 321,
:position {:bounding {:x1 423.9821548461914,
:y1 850.3928833007812,
:x2 509.6704788208008,
:y2 873.8214721679688,
:width 864,
:height 1296},
:rects ({:x1 423.9821548461914,
:y1 850.3928833007812,
:x2 509.6704788208008,
:y2 873.8214721679688,
:width 864,
:height 1296}),
:page 321},
:content {:text "atomically"},
:properties {:color "yellow"}}
{:id #uuid "6433e6e7-d995-4b69-96b3-261b79f94c1d",
:page 322,
:position {:bounding {:x1 715.2017593383789,
:y1 262.08929443359375,
:x2 746.7634048461914,
:y2 279.8035888671875,
:width 864,
:height 1296},
:rects ({:x1 715.2017593383789,
:y1 262.08929443359375,
:x2 746.7634048461914,
:y2 279.8035888671875,
:width 864,
:height 1296}),
:page 322},
:content {:text "sane"},
:properties {:color "green"}}
{:id #uuid "6433e729-7043-453b-8d60-6e6c41560543",
:page 322,
:position {:bounding {:x1 0,
:y1 125.14286422729492,
:x2 747.738899230957,
:y2 366.5625114440918,
:width 864,
:height 1296},
:rects ({:x1 0,
:y1 125.14286422729492,
:x2 0,
:y2 146.28571701049805,
:width 864,
:height 1296}
{:x1 712.866096496582,
:y1 323.2053642272949,
:x2 747.738899230957,
:y2 346.6339530944824,
:width 864,
:height 1296}
{:x1 171.90179443359375,
:y1 343.1339530944824,
:x2 366.5299377441406,
:y2 366.5625114440918,
:width 864,
:height 1296}),
:page 322},
:content {:text "synchronization primitives"},
:properties {:color "yellow"}}
{:id #uuid "6433eabf-48d6-4776-b66f-a5f7804d1ddc",
:page 323,
:position {:bounding {:x1 320.0720024108887,
:y1 195.0178680419922,
:x2 547.6788444519043,
:y2 212.94644165039062,
:width 864,
:height 1296},
:rects ({:x1 320.0720024108887,
:y1 195.0178680419922,
:x2 547.6788444519043,
:y2 212.94644165039062,
:width 864,
:height 1296}),
:page 323},
:content {:text " KEY CONCURRENCY TERMS"},
:properties {:color "yellow"}}
{:id #uuid "6433f35b-403b-4b25-b9f9-076e9e34777e",
:page 327,
:position {:bounding {:x1 585.9527893066406,
:y1 368.6517906188965,
:x2 738.0721740722656,
:y2 409.2232322692871,
:width 921.6,
:height 1382.4},
:rects ({:x1 585.9527893066406,
:y1 368.6517906188965,
:x2 738.0721740722656,
:y2 409.2232322692871,
:width 921.6,
:height 1382.4}),
:page 327},
:content {:text "Thread API"},
:properties {:color "yellow"}}
{:id #uuid "6433f45b-0345-4790-8379-3d1a94e57ef5",
:page 339,
:position {:bounding {:x1 617.5714492797852,
:y1 347.3571548461914,
:x2 691.9386367797852,
:y2 385.0714416503906,
:width 864,
:height 1296},
:rects ({:x1 617.5714492797852,
:y1 347.3571548461914,
:x2 691.9386367797852,
:y2 385.0714416503906,
:width 864,
:height 1296}),
:page 339},
:content {:text "Locks"},
:properties {:color "yellow"}}
{:id #uuid "6433f4ba-f2e4-4743-a536-e2b7747433b7",
:page 339,
:position {:bounding {:x1 140.0178680419922,
:y1 979.4018249511719,
:x2 325.5472869873047,
:y2 997.1161193847656,
:width 864,
:height 1296},
:rects ({:x1 140.0178680419922,
:y1 979.4018249511719,
:x2 325.5472869873047,
:y2 997.1161193847656,
:width 864,
:height 1296}),
:page 339},
:content {:text "A lock is just a variabl"},
:properties {:color "yellow"}}
{:id #uuid "6433f5e6-bc06-42a9-866e-e9a3053f528f",
:page 340,
:position {:bounding {:x1 0,
:y1 349.1428680419922,
:x2 745.5471057891846,
:y2 658.3750305175781,
:width 864,
:height 1296},
:rects ({:x1 0,
:y1 349.1428680419922,
:x2 0,
:y2 370.2857360839844,
:width 864,
:height 1296}
{:x1 0,
:y1 365.1428680419922,
:x2 0,
:y2 386.2857360839844,
:width 864,
:height 1296}
{:x1 706.2289886474609,
:y1 600.8125305175781,
:x2 745.5282440185547,
:y2 618.5268249511719,
:width 864,
:height 1296}
{:x1 171.89286994934082,
:y1 620.732177734375,
:x2 745.5471057891846,
:y2 638.6607360839844,
:width 864,
:height 1296}
{:x1 171.89286994934082,
:y1 640.6607360839844,
:x2 318.0395984649658,
:y2 658.3750305175781,
:width 864,
:height 1296}),
:page 340},
:content {:text "locks help transform the chaos that is traditional OS scheduling into a more controlled activity."},
:properties {:color "yellow"}}
{:id #uuid "6433fb69-1425-46b4-996f-f91da5d3e8d0",
:page 341,
:position {:bounding {:x1 452.08409881591797,
:y1 710.0000305175781,
:x2 525.8427047729492,
:y2 727.7143249511719,
:width 864,
:height 1296},
:rects ({:x1 452.08409881591797,
:y1 710.0000305175781,
:x2 525.8427047729492,
:y2 727.7143249511719,
:width 864,
:height 1296}),
:page 341},
:content {:text "efficacy "},
:properties {:color "green"}}
{:id #uuid "6433fbfd-a1bf-4fd9-a54d-e15189c77b15",
:page 342,
:position {:bounding {:x1 171.88867950439453,
:y1 179.01788330078125,
:x2 385.91197204589844,
:y2 200.732177734375,
:width 864,
:height 1296},
:rects ({:x1 171.88867950439453,
:y1 179.01788330078125,
:x2 385.91197204589844,
:y2 200.732177734375,
:width 864,
:height 1296}),
:page 342},
:content {:text "Controlling Interrupts"},
:properties {:color "yellow"}}
{:id #uuid "6433fe7e-2221-41ee-ad6b-7deaa4459aa5",
:page 343,
:position {:bounding {:x1 116.09821701049805,
:y1 691.2232360839844,
:x2 532.493236541748,
:y2 712.9375305175781,
:width 864,
:height 1296},
:rects ({:x1 116.09821701049805,
:y1 691.2232360839844,
:x2 532.493236541748,
:y2 712.9375305175781,
:width 864,
:height 1296}),
:page 343},
:content {:text "A Failed Attempt: Just Using Loads/Stores"},
:properties {:color "yellow"}}
{:id #uuid "6433ff4a-856d-4e4b-af30-6cb600aefeb5",
:page 343,
:position {:bounding {:x1 0,
:y1 509.1428680419922,
:x2 690.1883277893066,
:y2 893.2232666015625,
:width 864,
:height 1296},
:rects ({:x1 0,
:y1 509.1428680419922,
:x2 0,
:y2 530.2857208251953,
:width 864,
:height 1296}
{:x1 594.5398139953613,
:y1 855.3660888671875,
:x2 689.8509101867676,
:y2 873.0803833007812,
:width 864,
:height 1296}
{:x1 116.09821701049805,
:y1 875.294677734375,
:x2 690.1883277893066,
:y2 893.2232666015625,
:width 864,
:height 1296}),
:page 343},
:content {:text " use a simple variable (flag) to indicate whether some thread has possession of a lock."},
:properties {:color "yellow"}}
{:id #uuid "64340154-807c-4a7a-b783-045d5d6d3927",
:page 344,
:position {:bounding {:x1 347.09178161621094,
:y1 733.5803985595703,
:x2 635.6820526123047,
:y2 755.294677734375,
:width 864,
:height 1296},
:rects ({:x1 347.09178161621094,
:y1 733.5803985595703,
:x2 635.6820526123047,
:y2 755.294677734375,
:width 864,
:height 1296}),
:page 344},
:content {:text "Spin Locks with Test-And-Set"},
:properties {:color "yellow"}}
{:id #uuid "643401e0-fcec-41d3-9898-d5c4175ac464",
:page 344,
:position {:bounding {:x1 171.89287185668945,
:y1 903.1607666015625,
:x2 544.1298828125,
:y2 927.9286193847656,
:width 864,
:height 1296},
:rects ({:x1 435.919677734375,
:y1 903.1607666015625,
:x2 441.9018249511719,
:y2 915.1607666015625,
:width 864,
:height 1296}
{:x1 171.89287185668945,
:y1 904.5000610351562,
:x2 271.8574905395508,
:y2 927.9286193847656,
:width 864,
:height 1296}
{:x1 300.0535888671875,
:y1 904.5000610351562,
:x2 435.9386901855469,
:y2 927.9286193847656,
:width 864,
:height 1296}
{:x1 266.50001525878906,
:y1 907.357177734375,
:x2 544.1298828125,
:y2 925.2857666015625,
:width 864,
:height 1296}),
:page 344},
:content {:text "test-and-set (or atomic exchange1) instruction"},
:properties {:color "yellow"}}],
:extra {:page 345}}

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
-
-

View File

@ -1,2 +0,0 @@
- ![ostep.pdf](../assets/ostep_1680491762166_0.pdf)
-

View File

@ -1,5 +1,6 @@
file-path:: ../assets/ostep_1680491762166_0.pdf file-path:: ../assets/ostep_1680491762166_0.pdf
- ![OSTEP-book](../assets/ostep_1680491762166_0.pdf)
- virtualization, concurrency, and persistence - virtualization, concurrency, and persistence
ls-type:: annotation ls-type:: annotation
hl-page:: 1 hl-page:: 1
@ -616,22 +617,22 @@ file-path:: ../assets/ostep_1680491762166_0.pdf
ls-type:: annotation ls-type:: annotation
id:: 642fced7-c809-4d1e-bddb-da6474e851b8 id:: 642fced7-c809-4d1e-bddb-da6474e851b8
hl-color:: yellow hl-color:: yellow
- havoc - havoc 浩劫;灾害;祸患
ls-type:: annotation ls-type:: annotation
hl-page:: 173 hl-page:: 173
hl-color:: green hl-color:: green
id:: 642fcf85-6cfb-4eb9-aef2-ddcef7027b70 id:: 642fcf85-6cfb-4eb9-aef2-ddcef7027b70
- wreak - wreak 造成(巨大的破坏或伤害);施行(报复)
ls-type:: annotation ls-type:: annotation
hl-page:: 173 hl-page:: 173
hl-color:: green hl-color:: green
id:: 642fcf90-3133-4002-b986-4fd8157ab707 id:: 642fcf90-3133-4002-b986-4fd8157ab707
- ghastly - ghastly 可怕的;惨白的;惊人的;极坏的
ls-type:: annotation ls-type:: annotation
hl-page:: 174 hl-page:: 174
hl-color:: green hl-color:: green
id:: 642fcfa9-c026-4885-9f50-029ca80ce148 id:: 642fcfa9-c026-4885-9f50-029ca80ce148
- juncture - juncture 接缝;连接;接合;特定时刻,关头;
ls-type:: annotation ls-type:: annotation
hl-page:: 174 hl-page:: 174
hl-color:: green hl-color:: green
@ -1232,11 +1233,11 @@ file-path:: ../assets/ostep_1680491762166_0.pdf
hl-page:: 289 hl-page:: 289
hl-color:: green hl-color:: green
id:: 6433a2a0-7ba4-46cf-b1ec-fc02ce4c7916 id:: 6433a2a0-7ba4-46cf-b1ec-fc02ce4c7916
- hog - hog 多占;独占;(供食用的)猪
ls-type:: annotation
hl-page:: 289 hl-page:: 289
hl-color:: green ls-type:: annotation
id:: 6433a4fb-da6c-4741-a962-6c95c7fd9f0c id:: 6433a4fb-da6c-4741-a962-6c95c7fd9f0c
hl-color:: green
- swoop 俯冲;突然袭击;突击搜查;突然行动 - swoop 俯冲;突然袭击;突击搜查;突然行动
ls-type:: annotation ls-type:: annotation
hl-page:: 291 hl-page:: 291
@ -1301,42 +1302,42 @@ file-path:: ../assets/ostep_1680491762166_0.pdf
periodically move bottom of the *active* list to *inactive* list periodically move bottom of the *active* list to *inactive* list
within the 2 lists, manage pages in LRU order within the 2 lists, manage pages in LRU order
- When replacing, the candidate is taken from the *inactive* list. - When replacing, the candidate is taken from the *inactive* list.
- tract - tract 束;地带;小册子;大片土地
ls-type:: annotation ls-type:: annotation
hl-page:: 295 hl-page:: 295
hl-color:: green hl-color:: green
id:: 6433b29c-817e-44f0-a02e-8ab14f6fe764 id:: 6433b29c-817e-44f0-a02e-8ab14f6fe764
- yell - yell 大喊;喊叫;叫嚷;
ls-type:: annotation ls-type:: annotation
hl-page:: 296 hl-page:: 296
hl-color:: green hl-color:: green
id:: 6433b321-04d6-4118-9d04-80758598654e id:: 6433b321-04d6-4118-9d04-80758598654e
- scorn - scorn 轻蔑;不屑一顾;
ls-type:: annotation
hl-page:: 296 hl-page:: 296
hl-color:: green ls-type:: annotation
id:: 6433b345-d17f-48ea-b0d4-ec3eba091be4 id:: 6433b345-d17f-48ea-b0d4-ec3eba091be4
- subverted hl-color:: green
ls-type:: annotation - subvert 颠覆;暗中破坏;使背叛;
hl-page:: 297 hl-page:: 297
hl-color:: green
id:: 6433b6c0-0673-41c5-93a5-8280f5a6ab4b
- speculative
ls-type:: annotation ls-type:: annotation
hl-page:: 301 id:: 6433b6c0-0673-41c5-93a5-8280f5a6ab4b
hl-color:: green hl-color:: green
- speculative 推测的;投机的;
hl-page:: 301
ls-type:: annotation
id:: 6433b625-8749-4211-8d7a-3770dcd86ec2 id:: 6433b625-8749-4211-8d7a-3770dcd86ec2
- multitude hl-color:: green
- multitude 众多;群众;人群;大量
ls-type:: annotation ls-type:: annotation
hl-page:: 302 hl-page:: 302
hl-color:: green hl-color:: green
id:: 6433b5fa-2c4f-434c-9ab8-5142eb2cec45 id:: 6433b5fa-2c4f-434c-9ab8-5142eb2cec45
- shudder - shudder 战栗;强烈的震动;
ls-type:: annotation ls-type:: annotation
hl-page:: 305 hl-page:: 305
hl-color:: green hl-color:: green
id:: 6433bb38-56f9-47b1-b4d1-617c8693eb50 id:: 6433bb38-56f9-47b1-b4d1-617c8693eb50
- cheapskate - cheapskate 小气鬼;守财奴
ls-type:: annotation ls-type:: annotation
hl-page:: 306 hl-page:: 306
hl-color:: green hl-color:: green

View File

@ -0,0 +1,133 @@
file:: [ostep_1681115599584_0.pdf](../assets/ostep_1681115599584_0.pdf)
file-path:: ../assets/ostep_1681115599584_0.pdf
- # Part II
- thread
ls-type:: annotation
hl-page:: 311
hl-color:: yellow
id:: 6433ca28-1bdf-433d-8ed9-0d54bf5ba940
- share the same address space and thus can access the same data
- context switch: the address space remains the same
hl-page:: 311
ls-type:: annotation
id:: 6433cb70-d168-4863-8268-1e969df6ce06
hl-color:: yellow
- thread control blocks
ls-type:: annotation
hl-page:: 311
hl-color:: yellow
id:: 6433cb56-fbef-46da-83c2-13fa2dba2967
- thread-local storage: one stack per thread in the address space
hl-page:: 312
ls-type:: annotation
id:: 6433cba2-61bd-4549-a29f-2ad85b3e30cd
hl-color:: yellow
- Why thread?
- possible speedup through parallelization
- enable overlap of IO in a single program
- Though these could be done through multi-processing, threading makes share data easier
- KEY CONCURRENCY TERMS
ls-type:: annotation
hl-page:: 323
hl-color:: yellow
id:: 6433eabf-48d6-4776-b66f-a5f7804d1ddc
- **indeterminate**: the results depend on the timing execution of the code.
- race condition
ls-type:: annotation
hl-page:: 320
hl-color:: yellow
id:: 6433e4cc-69e4-4057-8cc6-1766240d82f4
- A **critical section** is a piece of code that accesses a shared variable (or resource) and must not be concurrently executed by more than one thread.
hl-page:: 320
ls-type:: annotation
id:: 6433e52b-1f38-4f7c-b168-0aed624f9bdf
hl-color:: yellow
- **mutual exclusion**: This property guarantees that if one thread is executing within the *critical section*, the others will be prevented from doing so.
hl-page:: 320
ls-type:: annotation
id:: 6433e566-e6ef-45b3-84b1-eba981be914a
hl-color:: yellow
- Atomicity: *as a unit*, or, *all or none*
hl-page:: 321
ls-type:: annotation
id:: 6433e6a1-407c-4936-b184-dee868ef4107
hl-color:: yellow
- synchronization primitives
ls-type:: annotation
hl-page:: 322
hl-color:: yellow
id:: 6433e729-7043-453b-8d60-6e6c41560543
- sane 精神健全的;神志正常的;明智的;理智的
ls-type:: annotation
hl-page:: 322
hl-color:: green
id:: 6433e6e7-d995-4b69-96b3-261b79f94c1d
- Thread API
hl-page:: 327
ls-type:: annotation
id:: 6433f35b-403b-4b25-b9f9-076e9e34777e
hl-color:: yellow
- `pthread_create` `pthread_join` `pthread_mutex_lock` `pthread_cond_*`
- Locks
ls-type:: annotation
hl-page:: 339
hl-color:: yellow
id:: 6433f45b-0345-4790-8379-3d1a94e57ef5
- A lock is just a variable
hl-page:: 339
ls-type:: annotation
id:: 6433f4ba-f2e4-4743-a536-e2b7747433b7
hl-color:: yellow
- **lock variable**: some type of variable, which holds the *state* of the lock(and maybe additional data such as its holder or a queue for acquisition)
- **lock state**: available (or unlocked or free); acquired (or locked or held)
- **lock routines**:
- `lock()` tries to acquire the lock. If no other thread holds the lock, the thread will acquire the lock and enter the critical section(become the owner of the lock). Otherwise, it will not return while the lock is held by another thread.
- `unlock()` : The owner of the lock calls `unlock()`, then it is *available* again. If there are waiting threads, one of them will (eventually) notice (or be informed of) this change of the lock's state, acquire the lock, and enter the critical section.
- Locks help transform the chaos that is traditional OS scheduling into a more controlled activity
hl-page:: 340
ls-type:: annotation
id:: 6433f5e6-bc06-42a9-866e-e9a3053f528f
hl-color:: yellow
- Controlling Interrupts
ls-type:: annotation
hl-page:: 342
hl-color:: yellow
id:: 6433fbfd-a1bf-4fd9-a54d-e15189c77b15
- For *single-processor* systems, **disable interrupts** for critical sections.
- Problems
- disable interrupts is privileged. In the worst case, the OS may never regain control when the interrupt isn't going to be enabled.
- does NOT work on multi-processor systems, each CPU has its own interrupt state
- importance interrupts may get lost
- inefficient
- Just Using Loads/Stores(Fail)
hl-page:: 343
ls-type:: annotation
id:: 6433fe7e-2221-41ee-ad6b-7deaa4459aa5
hl-color:: yellow
- use a simple variable (flag) to indicate whether some thread has possession of a lock
hl-page:: 343
ls-type:: annotation
id:: 6433ff4a-856d-4e4b-af30-6cb600aefeb5
hl-color:: yellow
- On acquisition, load, test the flag. If free, set the flag; If not free, spin-wait(loop load and test).
- On releasing, clear the flag.
- Problem
- When interrupted between load and test, *mutual exclusion* is broken.
- Low efficiency because of spin-waiting.
- Spin Locks with Test-And-Set
ls-type:: annotation
hl-page:: 344
hl-color:: yellow
id:: 64340154-807c-4a7a-b783-045d5d6d3927
- **test-and-set (or atomic exchange) instruction**
hl-page:: 344
ls-type:: annotation
id:: 643401e0-fcec-41d3-9898-d5c4175ac464
hl-color:: yellow
-
- efficacy
ls-type:: annotation
hl-page:: 341
hl-color:: green
id:: 6433fb69-1425-46b4-996f-f91da5d3e8d0