Atomic functions support on TriCore and Tasking

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User21707
Level 2
Level 2
First like received
Hi,

As per Tasking User Manual ( pg- 82 ) : __imaskldmst is an intrinsic atomic function. But if assembly instructions are checked, imask and ldmst are 2 separate atomic functions. So I have 2 queries on this -

1. How to make sure " __imaskldmst " is really an atomic function ? Similarly for imask, ldmst [ Any method of testing ? I have TC375TP board and Lauterbach debugger hardware with me ]

2. I understand that an atomic function while executing won't service any interrupt during its due process of functioning. Is this understanding correct? For instance, " __imaskldmst " is an atomic function
with 2 instructions i.e inst A, inst B. While __imaskldmst is called and inst A is being performed, an interrupt is serviced at the same very instant. Will the interrupt be serviced at the very moment or will be serviced after
inst B is completed. [Same scenario if ldmst is used instead of __imaskldmst , what would be the expected result ?]

3. Looking to use atomic functions for Multicore implementations. Any specific reading materials/tutorials that can be suggested for a better understanding of these concepts. It would be really helpful for some help here.

**To know the no of instructions, I am using the assembly file and also the performance counter to check. [ Kindly suggest other methods, if this is wrong or if the number of instructions of these functions can be found from manual ]

Thanks !!!
0 Likes
2 Replies
NeMa_4793301
Level 6
Level 6
10 likes received 10 solutions authored 5 solutions authored
See 2.10.3 Store Bit and Bit Field on page 42 of TriCore_TC162P_core_architecture_vol2of2_Instruction_set.pdf for a better example of how IMASK and LDMST work together.

IMASK merely sets up the mask and value; LDMST is the actual atomic Load-Modify-Store instruction. If an interrupt occurs between the IMASK and LDMST instructions, the registers should be saved and restored by the interrupt handler (as usual).

For more information on atomic operations, see 2.4 Semaphores and Atomic Operations on page 20 of TriCore_TC162P_core_architecture_volume_1_of_2.pdf. The details for each instruction are in volume 2.
0 Likes
User21707
Level 2
Level 2
First like received
Hello Wrangler,

Sorry for the late response on this thread. Went through the documentation and have an additional query. Please help!

Let suppose I want to perform a &= 0xFE using imaskldmst .

Initial value for a, a = 0x20

Imask operation, imask -> a & 0xFE = 0x20 [ bitoffset is 0 ,width is 1 ]

In meantime, an interrupt is serviced and value of a is updated as a= 0x21.

When ldmst is performed after the interrupt is serviced, my understanding is ldmst would function on value a = 0x20 and not a= 0x21. This would also overwrite the value of a i.e 0x21 is overwritte by 0x20 after the imaskldmst operation.

Hence I am loosing the a= 0x21 value which was acheived in the interrupt.

This is my understanding. Please correct me wherever I have gone wrong.

Motive is, the serviced interrupt value i.e a= 0x21, should be available for next cycle of operation.

Thanks !!
0 Likes