How to tell how many LOCKs are currently in use?
ags
Posts: 386
I'd like to know how many LOCKs are currently "allocated". In other words, of the 8 LOCKs available, how many times will LOCKNEW return a new lock ID?
A brute-force method is to call LOCKNEW, storing the returned ID each time, until it fails (returns -1). This would also require going through the stored lock IDs and releasing them with LOCKRET.
Is there another way?
A brute-force method is to call LOCKNEW, storing the returned ID each time, until it fails (returns -1). This would also require going through the stored lock IDs and releasing them with LOCKRET.
Is there another way?
Comments
Anyway, the short answer is that with a properly-written program, you should never have to worry about how many hardware locks are available.
-Phil
Not sure if I agree, but not sure if I disagree either (re: one lock per cog max).
I think I have a valid reason to want to know how many locks are available (or used): I implemented this for debugging a bootloader that I eventually diagnosed as failing after multiple calls because it never checked-in locks.
-Phil
I'm also open to comments on this shared bus design. If there are any suggestions I'll start a new thread.
Thanks for pointing this out, Phil. It's prompted me to think further on the subject.