PDA

View Full Version : OSC variable scope and OSCII-bot time scheduling explanation request


goldenarpharazon
02-03-2016, 01:10 AM
Having a real hard time with a single OSC script in OSCII-bot that is misbehaving causing flaky functionality of a Midi Control Surface.

On what basis does OSCII-bot schedule its @oscmsg, @midimsg and @timer code sections?

The problem is that key global variables needed to communicate/share data between @sections appear to be being updated & read asynchronously on different threads of execution. Unclear or undefined scheduling or re-entrancy of the @midimsg and @oscmsg sections is giving timing overlap related functionality bugs.

Assuming that every variable is truly global (except when explicitly declared as local) as stated here http://www.cockos.com/oscii-bot/oscii-bot-doc.html then how does the scheduling of the @sections work?

If a thread is part way through processing slowish code in @midimsg how and when does @oscmsg get called?, or is there a scheduler based on

a) all code is single threaded on a time slice that allows an @section to complete along with periodically running @timer
or perhaps
b) thread is interrupted and another thread executed as OSC data comes in to the network port's buffers

Given the functional but rudimentary OSCII-bot runtime and debug environment (a statement: but not a complaint!) it would be really useful to know this scheduling from "as documented behaviour" rather than spend a very long time experimenting and reverse engineering timing behaviours. The OSCII-bot source code suggests an answer somewhere in the mainProc function of midi2osc.cpp : but code reading has not yielded what is going on! Thanks

goldenarpharazon
02-06-2016, 03:11 PM
The thread ordering and sequence was gradually determined by using diagnostic debug printf() output to the OSCII-bot console log and by logging precise times using the time_precise() function call in the debug log.

The @midimsg and @oscmsg sections seem completely exclusive of one another and run on the same thread. Only one or the other runs at any one time making global variables thread safe within a script.

OSCII-bot coders relying on time and sequencing should note that in the standard console messages like this

TIME: 531.917 [OSC input] /fxparam/11/name [s] 1: Volume

that "TIME" here uses a less precise time stamp that does not always increment with wall clock time.