orocos-toolchain / ocl

Orocos Component Library
Other
16 stars 33 forks source link

os: added operations sleep and usleep to suspend execution of the calling thread #51

Closed meyerj closed 7 years ago

meyerj commented 8 years ago

Introduces four new operations in the os serivce provided by OCL:

Currently there is no way to sleep in Orocos scripting. And a common workaround for Lua is

os.execute("sleep 5")

which is even documented like that in the LuaCookbook. There is also an undocumented function rtt.sleep(sec, nsec) according to the related Orocos-users thread http://www.orocos.org/forum/orocos/orocos-users/sleep-ops-script, which is equivalent to the new nanosleep operation.

A general warning about sleep from http://www.orocos.org/forum/orocos/orocos-users/sleep-ops-script#comment-34824:

Adding such timeouts is often an indication of a questionable system architecture or deployment. If possible, I would recommend getting rid of such sleeps and instead making the necessary condition for continuing explicit, e.g. introduce a "ready event" or ready() operation which you can check in you script.

Markus

The new operation os.execute(command) can be convenient in deployment or cleanup scripts and enables future workarounds for similar problems.

smits commented 8 years ago

lgtm