真的不明白为什么我的程序不工作
我确实花了很多时间来解决这个问题并四处寻找解决方案,但我似乎找不到问题所在。
我正在学习如何编写 occam 代码并编写以下程序:
PROC light (CHAN OF BYTE screen, CHAN OF INT light.change)
INT light.on :
WHILE TRUE
SEQ
light.change ? light.on
IF
light.on = 1
screen ! 'y'
TRUE
SKIP
:
PROC test(CHAN OF BYTE keyboard, scr)
CHAN OF INT to.light :
INITIAL INT on IS 1(INT) :
BYTE b :
SEQ
light(scr, to.light)
WHILE TRUE
SEQ
keyboard ? b
IF
b = 'o'
to.light ! on
TRUE
SKIP
:
我想做的就是当我按“o
”键时从一个进程与另一个进程进行通信。
我从 (KRoC) 编译器收到的错误消息是:
Error at lift.occ:11
Program failed, state = e, eflags = 00000000
这是 light.on = 1
行。
据我所知, light
PROC
将等待其 light.change
channel
然后将其分配给其 light.on
变量
。然后,程序将继续执行条件语句 IF
,其中 light.on = 1
行在本例中应计算为 <代码>true。但我却收到了这个错误。
我尝试使用 -verbose
标志,但编译器表示您不能将其用于 .occ 文件。
有谁知道我如何或是否可以从编译器获取更详细的信息?
对此的任何帮助将不胜感激。
谢谢
I've really spent a lot of time working at this problem and googling around to find a solution, but I can't seem to find what's wrong.
I've learning how to code occam and have the following program:
PROC light (CHAN OF BYTE screen, CHAN OF INT light.change)
INT light.on :
WHILE TRUE
SEQ
light.change ? light.on
IF
light.on = 1
screen ! 'y'
TRUE
SKIP
:
PROC test(CHAN OF BYTE keyboard, scr)
CHAN OF INT to.light :
INITIAL INT on IS 1(INT) :
BYTE b :
SEQ
light(scr, to.light)
WHILE TRUE
SEQ
keyboard ? b
IF
b = 'o'
to.light ! on
TRUE
SKIP
:
All I'm trying to do is communicate from one process to another when I press the 'o
' key.
The error message I'm getting from the (KRoC) compiler is:
Error at lift.occ:11
Program failed, state = e, eflags = 00000000
which is the light.on = 1
line.
As far as I can see, the light
PROC
will wait for some input on its light.change
channel
and will then assign it to its light.on
variable
. The program will then proceed to a conditional statement IF
, where the light.on = 1
line should in this case evaluate to true
. But instead I get this error.
I have tried using the -verbose
flag, but the compiler says that you can't use it for .occ files.
Does anyone know how or if I can get more detailed info from the compiler?
Any help on this would be greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上面的代码为我编译,当运行达到死锁时,
我还可以让它以详细模式运行,如下所示
在不同的说明上,您可能想要更改结构。尝试使用三个 PROC
The above code compiles for me and when run reaches deadlock
I can also get it to run in verbose mode as below
On a different note you might want to change your structure. Try having three PROC's