Gaurav Dhiman escribió:
On 8/2/06, Deepak Joshi <deepak_cins@xxxxxxxxxxx> wrote:
Hi all,
In case of down_interruptible( ) i read following explination in
understanding linux kernel.
"It is widely used by device drivers since it allows processes that
receive
a signal while being blocked on a semaphore to give up the "down"
operation.
If the sleeping process is awakened by a signal before getting the
needed
resource, the function increments the count field of the semaphore and
returns the value -EINTR. On the other hand, if down_interruptible( )
runs
to normal completion and gets the resource, it returns 0. The device
driver
may thus abort the I/O operation when the return value is -EINTR."
so what type of signals they are talking abt ??? and how it is
implemented
??
plz explain it to me.
signal here are the signal delivered to user process like a signal to
abort or interrupt etc.
down_interruptible() puts the current process in TASK_INTERRUPTIBLE
state and puts it on semaphore queue of waiting processes and finally
calls schedule() functions to give up CPU to other process, by doing
so current process sleeps till the time state is not changed to
TASK_RUNNING. When a signal is delivered to some process and that
process is in TASK_INTERRUPTIBLE state, kernel changes the state from
TASK_INTERRUPTIBLE to TASK_RUNNING (making them a possible candidate
for selection in next schedule() call).
So by calling down_interruptible() we make sure that the current
process should be waked up either if we get the required resouce or if
we recieve any signal (whichever occurs earlier). On other hand down()
puts the current process in TASK_UNINTERRUPTIBLE state so it only
returns if and only if we are successfull in acquiring a resource.
Its advisable to use down_interruptible() than down() in normal cases.
Gaurav
Thanks and Regards,
Deepak Joshi
________________________________
All new Yahoo! Mail "The new Interface is stunning in its simplicity
and
ease of use." - PC Magazine
As Gaurav has stated, you should use down_interruptible in normal cases.
However you should take care, because using this you have two sources of
leaving the sleep mode; the adquisition of the semaphore, and the
reception of the interuption signal. So you should check the return
value of down_interruptible to see in which case you are.
Miguel Ángel
----------------------------------------- PLEASE NOTE -------------------------------------------
This message, along with any attachments, may be confidential or legally privileged.
It is intended only for the named person(s), who is/are the only authorized recipients.
If this message has reached you in error, kindly destroy it without review and notify the sender immediately.
Thank you for your help.
µSysCom uses virus scanning software but excludes any liability for viruses contained in any attachment.
------------------------------------ ROGAMOS LEA ESTE TEXTO -------------------------------
Este mensaje y sus anexos pueden contener información confidencial y/o con derecho legal.
Está dirigido únicamente a la/s persona/s o entidad/es reseñadas como único destinatario autorizado.
Si este mensaje le hubiera llegado por error, por favor elimínelo sin revisarlo ni reenviarlo y notifíquelo inmediatamente al remitente. Gracias por su colaboración.
µSysCom utiliza software antivirus, pero no se hace responsable de los virus contenidos en los ficheros anexos.
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/