sleeping from the RHS

5 views
Skip to first unread message

Bob Marinier

unread,
Mar 9, 2012, 9:09:52 PM3/9/12
to jsoar...@googlegroups.com
I'm trying to get Soar to yield the processor when it's just waiting. So I'm trying to add a RHS function call to Thread.sleep to the standard wait operator, like this:

sp "top-state*propose*wait
   (state <s> ^attribute state
              ^choices none
             -^operator.name wait)
-->
   (<s> ^operator <o> +)
   (<o> ^name wait)
   (javascript |java.lang.Thread.sleep(0)|) # since nothing to do, release the cpu for a moment
"

But I get this error during execution:

Error: Error executing RHS function 'javascript' with args [java.lang.Thread.sleep(0)]: No function 'javascript' registered

What am I doing wrong?

Thanks,
Bob

Bob Marinier

unread,
Mar 9, 2012, 9:12:40 PM3/9/12
to jsoar...@googlegroups.com
Ah, I needed to include this first:

script javascript { }

Bob

Dave Ray

unread,
Mar 9, 2012, 10:20:48 PM3/9/12
to jsoar...@googlegroups.com
You could have also just used (wait timeout) as well, I think.

https://code.google.com/p/jsoar/wiki/JSoarRhsFunctions

In theory, if the I/O code is written right, (wait) with no params
would suspend the agent until new input's available, but I'm sure
there are gotchas there.

Dave

> --
> You received this message because you are subscribed to the Google Groups
> "jsoar-user" group.
> To post to this group, send email to jsoar...@googlegroups.com.
> To unsubscribe from this group, send email to
> jsoar-user+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/jsoar-user?hl=en.

Bob Marinier

unread,
Mar 9, 2012, 11:58:49 PM3/9/12
to jsoar...@googlegroups.com
I knew there was some kind of functionality like this, but I didn't know the details. One potential issue with my agent is that it gets the cycle count as input, so there's always new input available. But it would be worth trying anyway.

Also, fwiw, sleep(0) had no effect (one core still maxed out), but sleep(1) worked nicely (cpu ~0%).

Bob
Reply all
Reply to author
Forward
0 new messages