BSO BSO - 3 months ago 29
C Question

Shared memory between threads

I am looking for C program source code. Could you please help me in finding the source code required mentioned below.

program to create multiple threads (one master thread and rest worker threads) and using the threads write into and read from shared memory.


All the global variables are shared memory area for thread. 'x' is global and share among all threads in following example.

int sharedx=0;
void *threadFunc(void *arg)
    printf(" %d %s", sharedx,(char*)arg);
int main(void)
    pthread_t pth[10];  // this is our thread identifier
    int i = 0;
    for(i; i<10; i++) {