-
-
Save floodric/91e0195b12dc9b21a6ea to your computer and use it in GitHub Desktop.
Resource blocking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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