aishpr February 2016

Change in evaluated expression when one term changes (multi-threaded)

In the C language, is there a way to dynamically see a change in the value of a variable based on change in another variable that it is related to (multi-threaded)?

For example, if I have a and b to be 2 globals, and I want a = 2*b always.

a = 2*b;

If b changes, in another thread, is there anyway to see that change in a if I switch into a thread that uses a?

Answers


fsasm February 2016

To have a changed when b changes only works in dataflow driven languages like VHDL, but this is for designing hardware. In C variables are only read when they are needed and not when they are modified.

When you are using threads, you can notify other threads that a variable changed, with condition variables.

Post Status

Asked in February 2016
Viewed 2,247 times
Voted 14
Answered 1 times

Search




Leave an answer