I’d like to know how to define shared memory region for shared data for
several subroutine and threads in several C source files in QNX ??
For example,.
( common data A, B, C)
sub1.c-------------------
how to define A,B,C??
void sub1() {
…
update A,B,C
…
}
sub2.c-------------------
how to define A,B,C??
void sub2() {
…
update A,B,C
…
}
I’d like to know how to define shared memory region for shared data for
several subroutine and threads in several C source files in QNX ??
For example,.
If all you use are threads, a global variable will do just fine.
If you want to share data between processes you
will have to setup shared memory. Check the shm_open()
and mmap() function.
Note that in both cases you may have to protect the
data with some sort of mecanism, typicaly semaphores
or mutexes. There is an article on that subject: http://qdn.qnx.com/articles/oct3101/index.html
( common data A, B, C)
sub1.c-------------------
how to define A,B,C??
void sub1() {
…
update A,B,C
…
}
sub2.c-------------------
how to define A,B,C??
void sub2() {
…
update A,B,C
…
}
I’d like to know how to define shared memory region for shared data for
several subroutine and threads in several C source files in QNX ??
For example,.
If all you use are threads, a global variable will do just fine.
If you want to share data between processes you
will have to setup shared memory. Check the shm_open()
and mmap() function.
Note that in both cases you may have to protect the
data with some sort of mecanism, typicaly semaphores
or mutexes. There is an article on that subject: http://qdn.qnx.com/articles/oct3101/index.html
( common data A, B, C)
sub1.c-------------------
how to define A,B,C??
void sub1() {
…
update A,B,C
…
}
sub2.c-------------------
how to define A,B,C??
void sub2() {
…
update A,B,C
…
}