Advertisement

Multi-threading?

Started by March 13, 2003 01:02 PM
1 comment, last by vaceX 21 years, 10 months ago
I''m currently making a small server program for a game. I want two separate processes/threads(/whatever): One for recieving data, and one for sendning data. Those two threads should be able to access the same variables. How should I do this? fork() ? Pthreads? (Linux)
Multiple threads can run in the same process, and can have access the same memory. POSIX threads (pthreads) offer the best method to access threading features in most unixes.

Processes do not share memory (although this can be worked around). The standard unix way to create processes is with fork.



[edited by - Null and Void on March 13, 2003 7:12:17 PM]
Advertisement
actually, processes can share memory pretty easily...

basically, you create a file (in /dev/shm, as current convention stands) mmap it, initialize it, then another process mmap''s it, and blammo! shared memory.

That''s the reccomended method, others include legacy things like sysV shm...

This topic is closed to new replies.

Advertisement