Skip to content

Instantly share code, notes, and snippets.

@floodric
Created April 1, 2015 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save floodric/91e0195b12dc9b21a6ea to your computer and use it in GitHub Desktop.
Save floodric/91e0195b12dc9b21a6ea to your computer and use it in GitHub Desktop.
Resource blocking
struct task{
param
done = 0
}
my_tasks[4];
for(i = 0..4){
my_task = new_task{param=i, done=0}
workqueue.put(my_task)
my_tasks[i] = my_task
}
while(!my_task[0].done && !my_task[1].done &&){// custom spin lock!
}
// never get here because no thread can get a good access to this resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment