[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reader/writer semaphores
Dear Bhanu,
Let me put it into simple words.
If you want to protect a write operation such as "a++" where "a" is global variable of your program/module (i.e. it is manipulated by your code only) then please use write semaphore. You will play safe.
Otherwise if "a" is a variable inside kernel and kernel exports this variable to be manipulated by other modules then usually kernel provides a lock as well for sync purpose and thus one should try to acquire that particular lock as suitable (read or write) and then manipulate it. You will play safe again.
Hope it clears your doubts.
Let me know if you still need mre clarification.
Cheers!
- A
On Mon, Apr 7, 2008 at 9:36 PM, bhanu nani <
bhanu.lnxnew@xxxxxxxxx> wrote:
Hi All,
debein,
I believe what you said. It was a misleading statement.
Did someone have a last chance top review my understanding and post
back the clarifications. this would very usefull for my future
understanding about the kernel.
Please let me know am I on the right track, if not please let me know
where am I missing.
Regards,
Mukund
> > Hi Fabio,
> >
> > My understanding: Semaphore are the tools to protect a region of code
> > by bloking access to other threads access while the first thead is
>
> An important point to note here is that you are not protecting the
> code, its the data structure
> or variable you are protecting.
>
> > global x;
> > up
> > /* critical section - any thing*/
> > *fpos+=count;
> > mystruct->size = *fpos;
> > mystruct->xxx = *fpos+ count;
> > down
> >
>