kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* confusion about locking [ Pls help ]
@ 2015-04-11 14:12 Er Krishna
  2015-04-12  9:00 ` michi1 at michaelblizek.twilightparadox.com
  0 siblings, 1 reply; 2+ messages in thread
From: Er Krishna @ 2015-04-11 14:12 UTC (permalink / raw)
  To: kernelnewbies

Hi All,

Can somebody help me here to understand  following basic scenario about
locking. Sorry if I am wrong in putting my points in correct manner.

1. Can we take semaphore (binary semaphore or mutex) if the critical
section data is shared across two  different threads/processes which are
running on two different processors simultaneously/parallely ? I know
spin_lock() can handle this scenario, but I was trying to understand can
semaphore also handle this scenario, assuming there is no interrupt and
only process context is there ? I think yes.  Pls confirm me on this and if
not then why not ? If any pross and cons are involved pls tell that also.


2. If the critical section data is shared across process and interrupt (
consider this scenario on uniprocessor machine  and I have not taken
local_irq_save() or any spin_lock_irqsave )  and in the currently executing
process  critical section is protected by  preempt_disable()  and suddenly
an interrupt occurs which also wants to access same critical section data,
so what will happen ? Will in  this case Interrupt handler  acquire the
critical section data and corrupt the kernel or it will sleep and corrupt
the kernel or it will keep doing busy waiting ? I think interrupt handler
will keep doing busy waiting and machine will stuck, kind of deadlock. Pls
confirm me.


3. Does Preemption gets disable ( on local processor ) in case of binary
semaphore or mutex ? I think no. Pls confirm. Second,  Lets say critical
section is shared across process and interrupt and it is locked by
semaphore (binary semaphore or mutex) in process context on  uniprocessor
machine.  If Interrupt comes then what will happen ? Will it preempt the
process and acquire the critical section of data and corrupt it or
interrupt will go into sleep mode and machine can  crash/stuck. Pls explain.

Best Regards,
Krishna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150411/3bebcb92/attachment-0001.html 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-12  9:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-11 14:12 confusion about locking [ Pls help ] Er Krishna
2015-04-12  9:00 ` michi1 at michaelblizek.twilightparadox.com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).