You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It might be interesting for soft-real time applications to implement a feature that can limit the physical time that a reaction is allowed to execute:
reaction(foo) {=
=} preempt (10 msec) {=
// Preempt the reaction after 10 msec has passed in physical time
=}
This can be currently done in the target language (at least in C) in many ways. One way to do it is the following:
reactor Foo {
input in:int;
preamble {=
int a = 0;
void *gpu_thread(void* nonsense) {
// CUDA
// Tensorflow
sleep(alongtime);
a = 5;
}
=}
reaction(in) {=
thread_t thread_id;
pthread_create(&thread_id, NULL, gpu_thread, NULL);
sleep(ashorttime);
if (a==0) {
// Took too long, kill the thread
return;
}
// Do important stuff
=}
}
This also ties into our previous discussions about pluggable scheduling where an external scheduler is called at certain controlled joints. The preempt keyword would in this case enforce/enable a credit-based scheduler.
The text was updated successfully, but these errors were encountered:
This is a really interesting idea. Setjump and longjump are another alternative way to implement this. Both techniques have risks: killing a thread can lead to inconsistencies in memory data structures and/or to memory leaks. Same with setjump and longjump. With disciplined programming, however, they can be made to work.
Another variant of this idea might be to provide clean support for anytime computation. Rather than just terminating the thread that takes too long, we have that thread checkpoint intermediate results. When the expires, we would terminate addition computation, as above, but use the latest checkpoint to provide approximate results.
It might be interesting for soft-real time applications to implement a feature that can limit the physical time that a reaction is allowed to execute:
This can be currently done in the target language (at least in C) in many ways. One way to do it is the following:
This also ties into our previous discussions about pluggable scheduling where an external scheduler is called at certain controlled joints. The
preempt
keyword would in this case enforce/enable a credit-based scheduler.The text was updated successfully, but these errors were encountered: