Solved

Thread Question

Posted on 2001-08-05
1
193 Views
Last Modified: 2010-04-21
I am working on a program, and I need to implement some threads.  It needs to compile under both windows and linux.  Right now I have the windows threads working using CreateThread.  What I'm looking for is a good way to do it under linux, that is compatible with the way it is done in windows.  (Basically all globals are shared and stacks are seperate.)  I looked at fork, and that looked wrong, because there is seperate global areas.  I then looked at __create(), and that looked like it would work, except that I couldn't figure out how/where to allocate and deallocate memory for the stack.  I've heard there is a pthread_create that might work also.  I'll give full points to whoever can post some small sample code that I can get to compile, that creates a few threads, accesses some global and local varibles, then quits correctly.
Thanks
Mithander
0
Comment
Question by:Mithander
1 Comment
 
LVL 2

Accepted Solution

by:
curri earned 200 total points
ID: 6354978
This page has an example of 2 threads, accessing a global var through a semaphore.

http://centaurus.cs.umass.edu/~wagner/threads_html/sect4.html

There is a page for linux threads with the library and pointers to several tutorials (including the above :)
http://pauillac.inria.fr/~xleroy/linuxthreads/
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Trying to install MonoDevelop from sourde on Ubuntu 14.04 trusty 10 596
check failing on yum update 5 31
fsstat very high only on nfs client side rhel 10 105
Cron jobs 12 136
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question