Permissions and concurrency: a breakthrough and a Grand Challenge
Richard Bornat (Middlesex, UK) 22nd Oct 2004
1
Permissions and concurrency: a breakthrough and a Grand Challenge - - PowerPoint PPT Presentation
Permissions and concurrency: a breakthrough and a Grand Challenge Richard Bornat (Middlesex, UK) 22nd Oct 2004 1 Typing one of the things that formalism has given us; 2 Typing one of the things that formalism has given us; a
1
◮ one of the things that formalism has given us; 2
◮ one of the things that formalism has given us; ◮ a relatively recent success (only took C in the early 90s); 2
◮ one of the things that formalism has given us; ◮ a relatively recent success (only took C in the early 90s); ◮ never a Grand Challenge; 2
◮ one of the things that formalism has given us; ◮ a relatively recent success (only took C in the early 90s); ◮ never a Grand Challenge; ◮ who could live without it? (well ok, low life). 2
◮ one of the things that formalism has given us; ◮ a relatively recent success (only took C in the early 90s); ◮ never a Grand Challenge; ◮ who could live without it? (well ok, low life). ◮ (why do the low life do without types? what can we do for
2
3
3
3
3
3
3
4
◮ dereferencing null pointers; 4
◮ dereferencing null pointers; ◮ double free; 4
◮ dereferencing null pointers; ◮ double free; ◮ rogue librarians (what does System.out.print(s) do?); 4
◮ dereferencing null pointers; ◮ double free; ◮ rogue librarians (what does System.out.print(s) do?); ◮ the ‘variant record error’; 4
◮ dereferencing null pointers; ◮ double free; ◮ rogue librarians (what does System.out.print(s) do?); ◮ the ‘variant record error’; ◮ ... 4
◮ dereferencing null pointers; ◮ double free; ◮ rogue librarians (what does System.out.print(s) do?); ◮ the ‘variant record error’; ◮ ...
4
◮ dereferencing null pointers; ◮ double free; ◮ rogue librarians (what does System.out.print(s) do?); ◮ the ‘variant record error’; ◮ ...
4
5
5
5
5
5
5
6
6
6
6
7
◮ Just a bastard child of BI (Pym, O’Hearn). 7
◮ Just a bastard child of BI (Pym, O’Hearn). ◮ E → E′ (points to) is permission to read/write/dispose cell at
7
◮ Just a bastard child of BI (Pym, O’Hearn). ◮ E → E′ (points to) is permission to read/write/dispose cell at
◮ → can also be read as ownership and/or a heap predicate. 7
◮ Just a bastard child of BI (Pym, O’Hearn). ◮ E → E′ (points to) is permission to read/write/dispose cell at
◮ → can also be read as ownership and/or a heap predicate. ◮ emp is no permission. 7
◮ Just a bastard child of BI (Pym, O’Hearn). ◮ E → E′ (points to) is permission to read/write/dispose cell at
◮ → can also be read as ownership and/or a heap predicate. ◮ emp is no permission. ◮ A ⋆ B (star) is separation of resource. 7
◮ Just a bastard child of BI (Pym, O’Hearn). ◮ E → E′ (points to) is permission to read/write/dispose cell at
◮ → can also be read as ownership and/or a heap predicate. ◮ emp is no permission. ◮ A ⋆ B (star) is separation of resource. ◮ A ∧ B (and) is identity of resource. 7
◮ Just a bastard child of BI (Pym, O’Hearn). ◮ E → E′ (points to) is permission to read/write/dispose cell at
◮ → can also be read as ownership and/or a heap predicate. ◮ emp is no permission. ◮ A ⋆ B (star) is separation of resource. ◮ A ∧ B (and) is identity of resource. ◮ A ∧ (B ⋆ true) is all A, partly B. 7
8
8
8
9
9
9
◮ Both proved sound by Brookes. 9
◮ Both proved sound by Brookes. ◮ A version of the CCR rule covers semaphores, in which C is
9
10
10
10
10
10
10
10
10
10
10
10
11
◮ Passivity is a property of a program and a resource: the program
11
◮ Passivity is a property of a program and a resource: the program
◮ We want to specify passivity by specifying a read-only resource. 11
◮ Passivity is a property of a program and a resource: the program
◮ We want to specify passivity by specifying a read-only resource. ◮ We require that a program, given a read-only resource, cannot
11
12
◮ Since Dijkstra, we have known that we can safely share
12
◮ Since Dijkstra, we have known that we can safely share
◮ Total permission E → E′, given by new, allows
12
◮ Since Dijkstra, we have known that we can safely share
◮ Total permission E → E′, given by new, allows
◮ Concurrent read permissions must be (⋆) separable, because of
12
13
◮ Splitting into multiple read permissions is easy. 13
◮ Splitting into multiple read permissions is easy. ◮ To write or dispose we have to know when we have all the read
13
◮ Splitting into multiple read permissions is easy. ◮ To write or dispose we have to know when we have all the read
◮ A program which doesn’t keep account leaks resource. 13
14
◮ Boyland (Wisconsin) developed a means of permission
14
◮ Boyland (Wisconsin) developed a means of permission
◮ He associates a number z with each permission: z = 1 total;
14
◮ Boyland (Wisconsin) developed a means of permission
◮ He associates a number z with each permission: z = 1 total;
◮ Fractional permissions are specification-only (cf. types). 14
◮ Boyland (Wisconsin) developed a means of permission
◮ He associates a number z with each permission: z = 1 total;
◮ Fractional permissions are specification-only (cf. types). ◮ In practice the arithmetic is very easy: fractions are simpler to
14
◮ Boyland (Wisconsin) developed a means of permission
◮ He associates a number z with each permission: z = 1 total;
◮ Fractional permissions are specification-only (cf. types). ◮ In practice the arithmetic is very easy: fractions are simpler to
◮ The magnitude of non-integral fractions doesn’t matter, except as
14
15
◮ Heaps are partial maps from Nat to (int, fraction). (Previously
15
◮ Heaps are partial maps from Nat to (int, fraction). (Previously
◮ A simpler model – just read / total permissions – fails to account
15
16
16
16
◮ Not (yet) proved sound by Brookes. (But surely ...) 16
17
17
17
17
17
17
17
17
17
◮ That is exactly how hard it is to use fractional permissions. 17
18
18
18
18
18
19
◮ We can prove termination monotonicity for all commands in our
19
◮ We can prove termination monotonicity for all commands in our
◮ Suppose {10 −
19
◮ We can prove termination monotonicity for all commands in our
◮ Suppose {10 −
◮ Then (frame rule)
19
◮ We can prove termination monotonicity for all commands in our
◮ Suppose {10 −
◮ Then (frame rule)
◮ – i.e. it won’t terminate in 10 −
19
◮ We can prove termination monotonicity for all commands in our
◮ Suppose {10 −
◮ Then (frame rule)
◮ – i.e. it won’t terminate in 10 −
◮ Therefore C isn’t in our language. 19
◮ We can prove termination monotonicity for all commands in our
◮ Suppose {10 −
◮ Then (frame rule)
◮ – i.e. it won’t terminate in 10 −
◮ Therefore C isn’t in our language. ◮ Thus we have passivity! 19
20
◮ Some programs naturally weigh out permissions to their child
20
◮ Some programs naturally weigh out permissions to their child
◮ Some programs count permissions: e.g. pipeline multicasting,
20
◮ Some programs naturally weigh out permissions to their child
◮ Some programs count permissions: e.g. pipeline multicasting,
◮ Permission counting is not specification-only. 20
21
22
22
22
22
22
22
23
◮ Heaps are partial maps from Nat to (int, permission). 23
◮ Heaps are partial maps from Nat to (int, permission). ◮ Permissions are −n (n read permissions), or +n (a “block” from
23
◮ Heaps are partial maps from Nat to (int, permission). ◮ Permissions are −n (n read permissions), or +n (a “block” from
◮ 0 is total permission. 23
◮ Heaps are partial maps from Nat to (int, permission). ◮ Permissions are −n (n read permissions), or +n (a “block” from
◮ 0 is total permission. ◮ E
23
◮ Heaps are partial maps from Nat to (int, permission). ◮ Permissions are −n (n read permissions), or +n (a “block” from
◮ 0 is total permission. ◮ E
◮ E E′ is a notational convenience for E
23
◮ Heaps are partial maps from Nat to (int, permission). ◮ Permissions are −n (n read permissions), or +n (a “block” from
◮ 0 is total permission. ◮ E
◮ E E′ is a notational convenience for E
◮ We have passivity (same proof as before). 23
24
24
24
25
25
25
25
25
25
25
25
26
26
26
26
27
27
27
◮ If I have x −
28
◮ If I have x −
◮ If I give you x −
28
◮ If I have x −
◮ If I give you x −
◮ In the concurrent/modular case, you might have the other half, or
28
◮ If I have x −
◮ If I give you x −
◮ In the concurrent/modular case, you might have the other half, or
◮ Moral: keep your hand on your ha’penny; don’t give them
28
◮ If I have x −
◮ If I give you x −
◮ In the concurrent/modular case, you might have the other half, or
◮ Moral: keep your hand on your ha’penny; don’t give them
◮ (Same applies to counting permissions.) 28
29
29
29
29
30
31
2 ⊢
2 , b 1 2 ⊢ listseg n f b} {front, tc, f 1 2 ⊢ front = f}
2 ⊢
2 ⊢ front = f}
31
2 ⊢
2 , b 1 2 ⊢ listseg n f b} {front, tc, f 1 2 ⊢ front = f}
2 ⊢
2 ⊢ front = f}
31
2 ⊢
2 , b 1 2 ⊢ listseg n f b} {front, tc, f 1 2 ⊢ front = f}
2 ⊢
2 ⊢ front = f}
31
2 ⊢
2 , b 1 2 ⊢ listseg n f b} {front, tc, f 1 2 ⊢ front = f}
2 ⊢
2 ⊢ front = f}
31
2 ⊢
2 , b 1 2 ⊢ listseg n f b} {front, tc, f 1 2 ⊢ front = f}
2 ⊢
2 ⊢ front = f}
31
2 ⊢
2 , b 1 2 ⊢ listseg n f b} {front, tc, f 1 2 ⊢ front = f}
2 ⊢
2 ⊢ front = f}
31
2 ⊢
2 , b 1 2 ⊢ listseg n f b} {front, tc, f 1 2 ⊢ front = f}
2 ⊢
2 ⊢ front = f}
31
2 ⊢
2 , b 1 2 ⊢ listseg n f b} {front, tc, f 1 2 ⊢ front = f}
2 ⊢
2 ⊢ front = f}
31
2 ⊢
2 , b 1 2 ⊢ listseg n f b} {front, tc, f 1 2 ⊢ front = f}
2 ⊢
2 ⊢ front = f}
32
2 ⊢
2 , b 1 2 ⊢ listseg n f b} {front, tc, f 1 2 ⊢ front = f}
2 ⊢
2 ⊢ front = f}
32
2 ⊢
2 , b 1 2 ⊢ listseg n f b} {front, tc, f 1 2 ⊢ front = f}
2 ⊢
2 ⊢ front = f}
32
33
◮ existence (no read, no write) permissions: e.g. P+V+read/write
33
◮ existence (no read, no write) permissions: e.g. P+V+read/write
◮ mobile channels: e.g. read one end, write the other in occam; 33
◮ existence (no read, no write) permissions: e.g. P+V+read/write
◮ mobile channels: e.g. read one end, write the other in occam; ◮ semaphores in the heap (for shared buffers which reclaim
33
◮ existence (no read, no write) permissions: e.g. P+V+read/write
◮ mobile channels: e.g. read one end, write the other in occam; ◮ semaphores in the heap (for shared buffers which reclaim
◮ mobile code, maybe (if David May will tell us how it works); 33
◮ existence (no read, no write) permissions: e.g. P+V+read/write
◮ mobile channels: e.g. read one end, write the other in occam; ◮ semaphores in the heap (for shared buffers which reclaim
◮ mobile code, maybe (if David May will tell us how it works); ◮ ... 33
34
34
◮ as lightweight as typing; 34
◮ as lightweight as typing; ◮ built into language designs; 34
◮ as lightweight as typing; ◮ built into language designs; ◮ built into compilers. 34
◮ as lightweight as typing; ◮ built into language designs; ◮ built into compilers.
34