This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
var n: Int = 0; | |
var favoredProcess: String = "first" | |
var processOneWantsIn: Bool = false | |
var processTwoWantsIn: Bool = false | |
func processOne(task: () -> Void) { | |
while n < 50 { | |
processOneWantsIn = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
var ran: Int = 0; | |
var favoredProcess: String = "first" | |
var processOneWantsIn: Bool = false | |
var processTwoWantsIn: Bool = false | |
func processOne(task: () -> Void) { | |
while ran < 50 { | |
processOneWantsIn = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class Semaphore { | |
var n: Int | |
init(n: Int) { | |
self.n = n | |
} | |
func P() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class Semaphore { | |
var n: Int | |
init(n: Int) { | |
self.n = n | |
} | |
func P() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class Semaphore { | |
var n: Int | |
init(n: Int) { | |
self.n = n | |
} | |
func P() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class Semaphore { | |
var n: Int | |
init(n: Int) { | |
self.n = n | |
} | |
func P() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class Condition { | |
var waiting: Bool | |
init() { | |
waiting = false | |
} | |
func wait() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Chopsticks: Array 0..4 of Chopstick; | |
Philosophers: Array 0..4 of Philosopher; | |
task type Philosopher is | |
end | |
task body Philosopher is | |
Left: Int; | |
Enumerator.Gimme_My_Number(Left); | |
Right: Int := (Left + 1) mod 5; | |
begin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Philosophers: Array 0..4 of Philosopher; | |
task type Philosopher is | |
end | |
task body Philosopher is | |
begin | |
loop | |
Table.Enter | |
Chopsticks.Request | |
Chopsticks.Request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task Alice is | |
end | |
task body Alice is | |
begin | |
loop | |
Yard.Request; | |
Walk_Dog; | |
Yard.Release; | |
end loop | |
end Alice; |
OlderNewer