-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polling a resource / poor-mans spinlock #76
Comments
That would be the way to do it currently. You could add the function though to check the level and determine if available. Why don't you just let it get in the queue though if it's not available? Are you checking to add it to the resource that is available (assuming you have more than one resource)? |
@hdavid16 , yes, it is because I am trying to avoid locking too many resources. However, I should admit that I am not experienced in this type of simulations, so maybe I am doing something wrong. Basically, I have a chain of resources and I have a process for each pair of resources. If I naively do the following: @resumable function establish_link(env, r1, r2)
@yield request(r1) & request(r2)
@yield timeout(longwaittime)
release(r1)
release(r2)
end
resources = [Resource() for i in 1:100]
for i in 1:99
@process link(env, resources[i], resources[i+1])
end then establishing all |
Ok. So basically you decrease the simulation time because you end up running every other link simultaneously and then you do the ones that were skipped, also simultaneously. Your approach of checking the availability is more robust than doing two loops, one for the odd |
We now have |
Is there a "proper" way to atomically check whether a resource is available in a non-blocking manner?
I want to write something along the lines of
I am currently thinking about using
resource.level == 0
but this seems like an internal implementation detail, not a real API.The text was updated successfully, but these errors were encountered: