Solved

Thread Question

Posted on 2001-08-05
1
191 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now