-
Notifications
You must be signed in to change notification settings - Fork 114
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
test and set utility #7
Comments
The test and set feature is a HW feature which does 2 operations atomically:
|
The value that you store in the variable when you make the unlock could be any values except -1, according to the number of bits chosen, is it right? Thank you in advance for the help. |
Yes indeed, the "normal value" of the variable should never be -1, otherwise you cannot distinguish between the case where the variable is locked or not. |
Thank you very much. I have another question, I tried to use the eight bits TAS but it didn't wok. I made something like this: RT_L1_DATA volatile signed char tas=-1; void function(){ ... Are there any mistakes in this piece of code? I tried also with an unsigned char variable. RT_L1_DATA volatile signed char tas; void function(){ ... In both cases the problem is that the program is not blocked by the while statements. What do you think about this? |
The lock should be initialized to something different from 0 otherwise it is already locked, that's why you never go out of the while loop. |
It is initialized to "-1" not to 0. In any case the problem is that the program is able to go out of the while loop. I would like that the program is blocked in the while loop in order to prove that the tas utility works well, but it doesn't happen. Thank you in advance for the help. |
Can you show the instruction traces for this code ? It is usually under build/pulp/trace_core_1f_0.log |
Since the program in which I'm using the TAS is much more complicated, I have made a simpler program that highlights the problem. This is the instruction trace: |
I cannot see any TAS access in this trace, can you send me your code ? |
Sure. In test.c I start the cluster. In cluster.c I make the fork and the TAS. |
I forgot to say that the 32 bits TAS works. The other TAS gave me these problems. Thank you in advance for the help. |
There was an issue with the tas functions, the return type was always "int", so the function was actually returning 255 instead of -1. |
Hello, thank you for your work. I would like to seek clarification about test and set utility located in the header "rt_utils.h":
There are three different functions that can be used to implement test and set behavior: rt_tas_lock_8, rt_tas_lock_16, rt_tas_lock_32. I would like to understand the differences between them.
The lock function takes as parameter an unsigned int variable called addr and return an int variable (int rt_tas_lock(unsigned int addr). I would like to ask you the meaning of these two variables.
Same question for the unsigned int addr and the unsigned char values taken as parameter by the rt_tas_unlock (unsigned int addr, unsigned char value) function.
The reason why I am asking these clarification is that in my program I need two integer semaphores or four binary semaphores.
Thank you in advance for the help.
The text was updated successfully, but these errors were encountered: