12 Discussion / Question Topics

Remove Filter
Member Avatar for
Member Avatar for can-mohan

Hi, I would linke to know what is the best way to synchronise the shared memory segment. is threads usage are also advisible whie synhcronising the shared memory segement. in what circumstances we should use threads or semaphore to synchronize the memory segment.

Member Avatar for rproffitt
0
457
Member Avatar for nikolaos

In the following example two threads share int counter. The increment_thread thread increases counter by one . The decrement_thread thread decreases counter by one . I use semaphore to control access to counter instead of making the two methods synchronized. Is this the proper way of using semaphore? When should …

Member Avatar for nikolaos
0
382
Member Avatar for haresh.sankarraj

Hi members, This is a program i wanted to implement semaphore between parent and child processes which are trying to access a shared variable called counter ... i dont know why it is not getting incremented during the child process !! someone help please !! #include <stdio.h> #include <sys/types.h> #include …

Member Avatar for rubberman
0
2K
Member Avatar for srivardhanms

Hi, I have two threads A and B. Thread A prints only odd numbers. Thread B prints only even number. I want to synchronize it in such a way that on the screen I get continues numbers. How can I do that? I was thinking of using sockets. Thread A …

Member Avatar for Yerbantherack
0
254
Member Avatar for devilmaycry1

hi friends I've a code to compute integral with area function in code. I used Fork, and for returned values I must use shared memory. now I need to embed a semaphore in my code to control the critical area(here is shared memory). I don't know how to embed semaphore …

Member Avatar for DeanMSands3
0
2K
Member Avatar for BryantFury

Hey guys I'm going through some questions, studying for exams and below is one which has had me stressing all afternoon. Consider a uniprocessor system executing concurrently two processes P and Q. Each process executes the code listed below, process P – procedure P, and process Q – procedure Q. …

Member Avatar for DeanMSands3
0
228
Member Avatar for kesuke

Can I use semaphore or mutex on MikroC? If you know , please tell me the function name or exsample code.

Member Avatar for I_m_rude
0
102
Member Avatar for Grenwood

Hey all, I was hoping I could get some advice on designing the proper threading for our project. A little background info - our company does simulators of complex electrical/mechanical systems. These simulators could have fuel systems, electrical systems, pneumatic pressure systems, etc. I suppose you can just think of …

Member Avatar for Grenwood
0
221
Member Avatar for smith32

[CODE] sem_t w,r,s1,s2,s3; pthread_mutex_t m; int main(int argc, char* argv[]) { mutex and semaphores initialization ..... call threads.... wait until finish and cancel threads... clean threads and semaphores [I]exit;[/I] } void *reader(void *argv) { while(TRUE) { sem_wait(&r); sem_wait(&s1); pthread_mutex_lock(&m); ... read data..... pthread_mutex_unlock(&m); sem_post(&s1); sem_post(&w); } printf("Done read\n"); sem_post(&extra2); pthread_exit(NULL); …

Member Avatar for Abhineet.Ayan
0
172
Member Avatar for smith32

I'm trying to do the third writer/reader problem with semaphore (as mention on wiki). But it's not working properly. First 16-element array seem to work properly. But after first, it got wrong. Even though I think I'm almost there, I can't find the error at all. My code is as …

0
142
Member Avatar for smith32

I don't get it why my threads can't perform properly for writer/reader problem. I think something with the semaphore. but can't solve and online can't help me too. [CODE] semaphore mutex, read, write; void *reader(void *argv) { char buffer[200]; int readNo, i=0; do { sem_wait(&read); sem_wait(&mutex); sem_getvalue(&read, &readNo); fgets(buffer, sizeof(buffer), …

0
96
Member Avatar for bangor_boy

My understanding of this subject is - Two or more processes accessing a semaphore concurrently can cause Deadlock The provelms with semaphores is that you can forget to call the release method and it can cause deadlock Starvation Both processes can change the P and V counters of the semaphore …

Member Avatar for Old Doctor Ed
0
182

The End.