race condition on open ?

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

 



Hi,
I am implemnting a character device driver for uniprocessor system, kernel 2.4.7.
mydev_open is the implementation of open system call.
the devices are /dev/mydev1, /dev/mydev2, etc with minors starting at 0.
While a Process 1 opens mydev_open for /dev/mydev1, it will update the instance variable which is global in the driver.
Like,


instances = 0 ;
mydev_open() {
....
instances ++;
....
}
mydev_close () {
...
instances --;
...
}

My doubt is that, in a uniprocessor system, shall I protect instances variable with a semaphore? I know that the kernel paths are non preemptible. Does it mean that unless the driver calls a schedule(), the kernel paths executions will not be interleaved?

Thanks
Om.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux