Let's say that the function isr_callback() is called on hardware interrupts. If my_function() sets the variable data to 0, and waits for tx_complete_semaphore, will the variable data be updated to 1 in my_function() when tx_complete_semaphore is released by isr_callback()? Or does the variable data have to be qualified as volatile to be updated properly in my_function()?
static int data;
static rtems_id tx_complete_semaphore;
void isr_callback(void)
{
data = 1;
/* interrupts as disabled here */
rtems_semaphore_release(tx_complete_semaphore);
}
void my_function(void)
{
data = 0;
/* data will be 0 here */
printf("data is %i", data)
/* Interrupts are enabled here */
rtems_semaphore_obtain(tx_complete_semaphore,
RTEMS_WAIT,
RTEMS_NO_TIMEOUT);
/* what is the value of data here? */
printf("data is %i", data);
}