LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-26-2008, 07:14 AM   #1
tanmay.anjaria
LQ Newbie
 
Registered: Jan 2008
Posts: 8

Rep: Reputation: 0
Linux Multi Threading Options Exploration


Hello,

I'm going to use linux threads for the first time and a bit confused with difference between 3 terms seen while browsing/reading...

"native threads", "posix threads" and "linux threads".

I've a system having quad processors. I want to run a program which creates four threads and runs each one of them on different processor. I'm doing it by setting the "sched_setaffinity".

My question is that how many TYPES of threading options do I have? and what are characteristics of each of them?

I've used posix threads (pthread library functions) currently.

I've heard that the use of native threads will be effective here. Can some one throw some light or point me some material/link for understanding the difference between NATIVE THREADS and POSIX THREADS?
====================================================

which one of the two will have easier sync mechanism (semaphore/mutex)?

Thanks in advance

Tanmay
 
Old 02-27-2008, 12:46 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
In general, don't use sched_setaffinity, the system has other things to do besides your prog, like the OS for a start.
It's usually recommended to let the kernel handle thr/cpu distribution, which it does in real time as demands alter.
Of course if you are writing a kernel, go for it.
 
Old 02-27-2008, 12:59 AM   #3
tanmay.anjaria
LQ Newbie
 
Registered: Jan 2008
Posts: 8

Original Poster
Rep: Reputation: 0
thanks chris, for answering...

and ya, I'll need to use affinity setting in accordance with kernel change.

But can you please address my real concern here?

I'm trying to clear my thoughts on NATIVE and POSIX threads...

Can you tell me the difference between "native", "posix" and "linux" threads?

Thanks,
Tanmay
 
Old 02-27-2008, 01:10 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Afraid that's out of my league, I use Perl, which does threads if I want, but it determines how, not me, which is fine.
You'll have to google some more or wait until someone who knows comes by.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-threading in PHP under LINUX? sunilvadranapu Programming 1 04-04-2007 08:24 AM
multi threading slower than single threading on dual core. why? nebojsa.andjelkovic Programming 13 01-30-2007 09:56 PM
problems about multi-threading and/or multi-processing with tcp network in java ... alred Programming 5 06-23-2006 03:21 PM
Multi-threading rch Programming 3 03-30-2003 10:27 PM
Multi threading Mohsen Programming 5 03-01-2003 11:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration