Accessing interface functions while server thread is busy Topic is solved

If you have a simple question and just want an answer.
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Accessing interface functions while server thread is busy

Post by DemoniacMilk »

I just thought about something pretty basic:
Let's say a server thread notifes multiple clients that it has data ready and the clients immediately react to the notification by asking for data via an interface function: What actually happens?

My guess is, that the server finishes whatever code section it was running when notifying the clients, in a select() statement that would be until break;
Now the server has multiple requests. I guess it just handles the requests one after another, as

Code: Select all

case some_interface[int i].some_function():
  do_something();
  break;
is probably translated into something like

Code: Select all

case some_interface0.some_function():
  do_something(0);
  break;
case some_interface1.some_function():
  do_something(1);
  break;
[..]
and the clients have to wait for their request to be served?


View Solution
robertxmos
XCore Addict
Posts: 169
Joined: Fri Oct 23, 2015 10:23 am

Post by robertxmos »

Yes,
This is co-operative multitasking.

Tasks are not pre-empted to simulate parallelism, but decide for themselves when to yield to another task. Normally the yielding will occur when the task has finished, but you could divide a large task up for completion in the background.

As for priority, this is undefined but currently depends upon the resources ID (IIRC lowest first). Where priority order is required an ordered-select statement should be used.

Using co-operative multitasking allows the tools to work out the worse case timings and resource usage etc. This allows 100% of a resource to be used with the worse case senario being better than with pre-emptive!

Circular dependencies, where a server calls a client that may call back to the original client, are also handled within the tools - where this may happen, a yielding mechanism is added when compiling the interface.