Solved

Thread Question

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to import linux vhd to sccvmm 1 150
Debian 3.16.7 3 136
linux $PWD 2 591
monitor and log every file access on redhat/linux 4 115
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…
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 demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

947 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

21 Experts available now in Live!

Get 1:1 Help Now