Solved

Thread Question

Posted on 2001-08-05
1
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Debian 3.16.7 3 157
Automating a set of commands run on linux 7 106
Subsystem for UNIX-based Applications (SUA) 2 94
Why  my code (program) build with old compiler? 11 147
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 shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 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