Commit fb706e66 authored by Sebastian Biewer's avatar Sebastian Biewer
Browse files

Fixes #21

parent 142001ee
......@@ -471,6 +471,18 @@ class PCCCompiler # ToDo: Allow assigning a recently used program controller (
@emitMatch("lock", i, a)
@emitProcessApplication("Mutex", [i, new PCCBinaryContainer(c, new PCCConstantContainer(1), "+"), a])
control.setBranchFinished()
control = @emitChoice()
r = new PCCVariableContainer("r", PCCType.INT)
@emitInput("multilock", i, r)
@emitProcessApplication("Mutex", [i, new PCCBinaryContainer(c, r, "+"), a]) # add r reentrances to current counter c
control.setBranchFinished()
control = @emitChoice()
@emitOutput("fullunlock", i, c)
@emitProcessApplication("Mutex", [i, new PCCConstantContainer(0), a])
control.setBranchFinished()
@emitInput("unlock", i, a2)
control = @emitChoice()
@emitCondition(new PCCBinaryContainer(a, a2, "=="))
......
......@@ -613,9 +613,11 @@ PC.PrimitiveStmt::compile = (compiler, loopEntry) ->
compiler.emitOutput("add", c, null)
g = compiler.getVariableWithNameOfClass("guard", null, true).getContainer(compiler)
a = if compiler.useReentrantLocks then compiler.getVariableWithNameOfClass("a", null, true).getContainer(compiler) else null
compiler.emitOutput("unlock", g, a)
r = compiler.getFreshContainer(PCCType.INT)
compiler.emitInput("fullunlock", g, r)
compiler.emitOutput("wait", c, null)
compiler.emitOutput("lock", g, a)
compiler.emitOutput("multilock", g, new PCCBinaryContainer(r, new PCCConstantContainer(1), "-")) # perform the r-1 remaining reentrant calls of lock using multilock
entry.emitCallProcessFromFrame(compiler, compiler.getProcessFrame())
control.setBranchFinished()
compiler.emitCondition(b)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment