Re: Locking IOCTL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi Praveen,

On Tue, Nov 15, 2011 at 4:23 AM, Praveen kumar <chatpravi@xxxxxxxxx> wrote:
> The driver is opened by multiple processes, One such process is a
> diagnostics.
> Where I am checking sanity of some of the registers if I make ioctl open for
> all the processes.It can screw
> up my diagnostics check.(write some values to registers). This is basic
> reason I am using lock to my ioctl.

So "locking the data" means that you should create a lock for the data
registers in question.

You should acquire the lock around writing the values to the
registers, and presumably around reading them.

Acquiring the lock is about accessing the registers, not calling the
ioctl, even if today the only place that you access the registers is
from the ioctl. What happens if down the road you decide to add some
type of monitoring thread and it needs to access the registers? It's
not in an ioctl, so acquiring some type of ioctl lock is misleading.
The data that the lock is tied to is the registers, so make the code
work that way.

Also, som paths through the ioctl might not need to access the
registers, so you don't need or want to acquire the lock for those
cases.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Networking]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

Add to Google Powered by Linux