我正在尝试获取单个进程的 who id(进程是乌龟),但我收到此错误:“cpu 0 不是 PROCESS 错误,而观察者运行 PROCESS。由过程 GO 调用。由按钮调用调用”
我需要这个 who id,因为我希望只有队列的第一个进程(具有最大优先级的进程)才能到达 cpu 的“未占用”核心(如果可能)。
我发现当我要求单个进程执行指令时出现错误。它不在乎什么是动作(我试图改变结构)。问题是“询问进程 N [...]”。
to go
if ticks > 0 and ticks mod 10 = 0 and number-of-processes < max-number-of-processes
[
create-processes 1[
set color green
set shape "square"
set size 2
set xcor 0
set ycor 0
]
;set whonumber [who] of process current-process --> it'doesn't work.. same error below
ask process current-process [set whonumber who ] ; --> current-proces is a variable that start to 0.. yeah i've tried also to put 0 instead.. doesn't work
set mylist lput one-of processes with[who = whonumber] mylist
set number-of-processes number-of-processes + 1
set current-process current-process + 1 ;verificare se quando muore un processo l'assegnazione sia sempre sequenziale oppure debba fare -1 in caso di die
]
;TO DO : MOVE THE SPAWNED PROCESS TO THE (turtle)QUEUE IF POSSIBLE
ask processes [show who]
if any? cores with [core-taken = false] and number-of-processes > 0 [
; ask cores with [xcor = ([xcor] of one-of other processes)] [set core-taken true] ---> doesn't work.. the comand face doesn't reach the same core coord...
ask processes with[ who = [who] of process item 1 mylist] [face unused-core forward 1] ; this action in the future will be done by the first project in the turtle queue
]
tick
end
谢谢你的帮助