LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 09-29-2006, 03:13 PM   #1
yyanovsk
LQ Newbie
 
Registered: Sep 2006
Posts: 4

Rep: Reputation: 0
Race conditions in 2.4 between tasklet and sys.call


Hello everyone, I've got a question about race conditions.
I'm writing the dev.drv and have to share some data between user processes(sys.call) and tasklet.
The shared data is stored in cyclic queue.
My write() sys.call pushing the data to queue and the tasklet pulling the data and writing it to I/O port.
Do I have to use some lock/unlock mechanisms to protect my deque(), enqueue() functions?
The tasklet could be raised by HW INT or from my write() sys.call.
The kernel version is 2.4.32 and the arch. is I386.

Thanks a lot.
 
Old 10-01-2006, 12:08 AM   #2
gaihua
LQ Newbie
 
Registered: Apr 2006
Posts: 18

Rep: Reputation: 0
Of course, you have to lock it before you read or write into the Queue.
 
Old 10-01-2006, 12:09 AM   #3
gaihua
LQ Newbie
 
Registered: Apr 2006
Posts: 18

Rep: Reputation: 0
Of course, you have to lock it before you read or write into the queue
 
Old 10-03-2006, 10:11 AM   #4
yyanovsk
LQ Newbie
 
Registered: Sep 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks a lot for the answer.. I'll try to add lock/unlock in both enqueue/dequeue functions to solve my problem.
But the question is my basic understanding of 2.4 kernel.
As I understand, the 2.4 kernel series are non-preemtive, which means till one system call is not ended (if we talking about single processor machine), nothing could interrupt the system call except the Hardware interrupt.
So, if in HW INT routine (isr()) noone tries to touch the queue (no enqueue/dequeue calls), this means all other calls to dequeue/enqueue are synchronous. If this is correct, why should I to add synchronizing mechanisms into enqueue/dequeue functions?
 
Old 10-05-2006, 11:33 AM   #5
gaihua
LQ Newbie
 
Registered: Apr 2006
Posts: 18

Rep: Reputation: 0
yes. you have to prevent some other process to access the queue when your process reading or writing into the queue.
 
  


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
question about select sys call xatzipol Programming 1 10-30-2005 09:22 AM
Write sys call failing ppy Programming 1 11-05-2004 08:57 AM
Any sys call to list all users ? dileepkk Linux - General 5 07-06-2004 06:04 PM
Kill sys call eshwar_ind Programming 4 05-07-2004 11:41 AM
any sys call to get ip address of NIC jmdey Linux - General 2 05-30-2002 03:09 PM

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

All times are GMT -5. The time now is 12:32 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