![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Threads and Threads Count ? | varungupta | UNIX for Advanced & Expert Users | 2 | 03-21-2008 06:23 PM |
| how to read POSIX? | robin.zhu | UNIX for Dummies Questions & Answers | 3 | 07-15-2006 07:07 AM |
| what can I get the posix standard? | crashsky | UNIX for Advanced & Expert Users | 2 | 02-11-2004 10:30 PM |
| Unix(posix) | Haris Astreos | High Level Programming | 1 | 11-10-2002 07:45 AM |
| ANSI C vs POSIX | bb00y | High Level Programming | 2 | 11-05-2002 06:20 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
POSIX threads
Hello !
Let's supose I have a main function in C , and two POSIX threads. I give you an example down : Code:
int main() {
int something;
char else[];
void *FirstThread();
void *SecondThread();
..
<start those two pthreads ..>
return 0;}
void *FirstThread() { ... }
void *SecondThread() { ... }
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Are you asking if you create two threads, can they modify the same memory?
Yes. You prevent that by: 1. keeping almost all the variables they change declared local to the function. That way they cannot hurt anybody else's data. 2. For shared data, set up a mutex, so that only one function is able to change shared data at one time. In your case, if you pass a reference to int and char to both functions, then you have a problem. |
|
#3
|
||||
|
||||
|
Oh yes , I figure it out.
Thanks again ! |
||||
| Google The UNIX and Linux Forums |