LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-28-2014, 03:53 PM   #1
amitragarwal
LQ Newbie
 
Registered: Sep 2013
Posts: 2

Rep: Reputation: Disabled
Workqueue Depth


Hi,
I am trying to use workqueue to handled shared buffer in multi process system. Any process can come in and queue the work which can be processed in sequential order in worker thread. Semaphores don't help because they starve higher priority thread in such scenario.

The question is what is the depth of a workqueue? I see linked list implementation but how do I know when to limit processes to queue more work on this wq? If I don't limit them, the system is very unstable.

Thanks
 
Old 04-28-2014, 08:27 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,809
Blog Entries: 4

Rep: Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981Reputation: 3981
One way to do this, with POSIX semaphores, is to initialize a semaphore to a value equal to the maximum buffer-depth you want. A process wishing to add an entry must first sem_wait() on a semaphore which contains this count. It then is entitled to add an entry to the queue, which action is controlled by another (this time, binary) semaphore. The consumer process that removes entries from the buffer then issues a sem_post() against the count semaphore to allow processes that are waiting for permission to post a new entry to do so.

Notice there are two semaphores. One, with a count, controls the size of the buffer. The second, binary, secures the shared data-structure itself.
 
  


Reply


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
workqueue priority animesh Linux - Kernel 2 09-11-2013 07:55 AM
Enabling tracing of workqueue ... beyefendi Linux - General 0 05-04-2012 03:08 AM
Kernel 2.6.22 and WorkQueue problems linux_nagendra Linux - Kernel 2 03-31-2010 06:08 AM
Help me with linux workqueue pvpnguyen Programming 3 08-25-2007 06:05 PM
Can we do BlockingI/o in workqueue jendeavor Linux - Kernel 1 06-15-2006 12:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:09 AM.

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