Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 03-19-2008, 09:00 AM   #1
LQ Newbie
Registered: Mar 2008
Distribution: Fedora
Posts: 1

Rep: Reputation: 0
How immediate is sched_setaffinity

I have a multi-threaded application that currently runs with one thread dedicated to a particular cpu. The system is a dual cpu system that runs without hyperthreading. The dedicated thread does so in order to access a hardware device that must be accessed from a specific cpu.
The dedicated thread acts as a server that takes queued requests from the other threads of the application. This servicing mechanism required locking and signaling. I would like to optimize this app by having each of the threads temporarily dedicate to the appropriate cpu to access the device.

So I have a couple of questions:

1. Is there a lightweight method for a thread to determine which cpu it is currently running on?

2. How immediate is the effect of sched_setaffinity. Is the calling thread guaranteed to be on the requested cpu upon return?

3. If the thread must make a pass through the scheduler to guarantee affinity, is there a fast "resched" system call? (sched_yield is way to slow to be effective)

By the way.. The system is running Fedora Core6 and is therefore running the 2.6 kernel.

Thanks in advance.


cpuaffinity, performance, threads

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
difference between set_cpus_allowed() and sched_setaffinity() asurya Linux - General 1 12-01-2006 10:52 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:18 PM.

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