Re: [LIP] Question about Linux kernel

Rakesh Avichal Ughreja <[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Organization Samsung India Software Operation
Message-ID <[email protected]>
Hi,

Thanks alot for your help.

As I understood your and Sridhar's answer, default linux kernel without any
patches is a non_pre_emptive.

All Linux drivers should re-entrant, since they may run on SMP machines
also.

I can use semaphores and spinlocks.

But I think using spinlocks is a good choice because its not good to spend
on semaphore if you are in ISR.

Thank you very much once again.

Regards
Rakesh



----- Original Message ----- 
From: "Amod Malviya" <[email protected]>
To: <linux-india-programmers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Sent: Monday, May 31, 2004 12:23 PM
Subject: Re: [LIP] Question about Linux kernel


> Linux kernel is not pre-emptive. But you should be writing re-entrant
drivers, since on SMP machines, re-entrancy would come into picture. Also,
the kernel may go for a pre-emptive nature later on (maybe its there in 2.6,
not sure since haven't tried it till now). Queues are already implemented in
linux, with mutual exclusion features. However, you can use your own.
Regarding the mutual exclusion, you can use either semaphores or spinlocks.
A good documentation to start with is Rubini's Writing Linux Device Drivers
( http://http://www.xml.com/ldd/chapter/book/ )
>
> --Amod
>
> ----- Original Message -----
> From: Rakesh Avichal Ughreja <[email protected]>
> Date: Mon, 31 May 2004 12:13:26 +0530
> To: LIP <linux-india-programmers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Subject: [LIP] Question about Linux kernel
>
> > Is Linux kernel pre-emptive ?
> >
> > I have a question about Linux kernel. I am writing a char driver, in
which I
> > have implemented my own queues for reader and writer. I don't know if
such
> > queues are already available in Linux.
> >
> > Whenever my driver receives interrupt from device, it gets the packet
from
> > devices memory and enqueues into the Rx queue.
> >
> > In the device_read call, i want to dequeue packet from this queue and
want
> > to send it to user using copy_to_user.
> >
> > How do I take care of mutual exclusion here ? One obvious thing is
whenever
> > ISR is getting executed I am sure its an atomic operation and my reader
> > process will not get chance to run, but I don't know what will happen if
an
> > interrupt comes while reader is dequeueing the packet from the queue.
> >
> > How can I make enqueue and dequeue functions atomic ?
> >
> > Thanks in advance.
> >
> > Regards,
> > Rakesh
> >
> > -----------------------------------------------------------
> > "Behind every successful woman, is a man who is surprised."
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: Oracle 10g
> > Get certified on the hottest thing ever to hit the market... Oracle 10g.
> > Take an Oracle 10g class now, and we'll give you the exam FREE.
> > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> > _______________________________________________
> > linux-india-programmers mailing list
> > linux-india-programmers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> > https://lists.sourceforge.net/lists/listinfo/linux-india-programmers
>
> -- 
> ______________________________________________
> Check out the latest SMS services @ http://www.linuxmail.org
> This allows you to send and receive SMS through your mailbox.
>
>
> Powered by Outblaze
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... Oracle 10g.
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> _______________________________________________
> linux-india-programmers mailing list
> linux-india-programmers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/linux-india-programmers
>
>



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.