c pthread global variables - no write access / no update -
i have problem writing global variables in pthreads. variables defined in head of code ->
int iplcwritereal;
i created functions , called them on pthreads.
in main threads called ->
ithreadresult = pthread_create(&threadweb, null, pthreadwebserver, &ftest); pthread_join(threadweb, null);
the problem when write global int
thread - value not updated in own thread , not in other threads (iplcwritereal = 34;).
there 3 threads , every threads has wihile(1) loop inside-> read data / webserver / archive data
with mutex function lock&unlock had no success.
with pointer & malloc
had no luck. passed pointer trough threads - address right 1 - value not updated.
the communication global data working when don't use while(1) - loop - there problems when use loop in pthreads writing global values ? maybe sync / update functions ?
i found problem-> fork() problem.
the fork() makes copy own process , using actual values share/global data. fork-process can not directly access global data.
instead of fork made pthread inside pthread - , working.
thx
Comments
Post a Comment