Concurrent accesses to sysfs

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

 



Hi,

I'm implementing a user-space API that will give access to 
custom hardware features through sysfs. This library is here
to hide the sysfs specifics.

This library must support multi-threaded accesses.

I would like to know if something special must be done in
this library to assure concurrent accesses.

Here is an example :

I want the users of my library to be able to switch-on/-off a LED using
a simple function like the following :

platform_led_on(0); //switches on led '0'
platform_led_off(0); //switches on led '0'

This led is declared in my platform_data in the board init file as a 
gpio_led and can be seen in sysfs under /sys/class/leds/led0

the platform_led_on/off(0) functions will :

- build the sysfs path to the led0 based on the argument (0)
- open the brightness file in the sysfs path
- write to the brightness file a value != 0 to switch the led on or 0 to switch it off
- close the brightness file
- return

Now what will happen if a thread tries to switch on the led while another
thread tries to switch it off ?

Thank your for your comments / help.

Best regards,

-- 
Christophe Aeschlimann

Embedded Software Engineer

Advanced Communications Networks S.A.

Rue du Puits-Godet 8a
2000 Neuchâtel, Switzerland

Tél. +41 32 724 74 31

c.aeschlimann@xxxxxxxxxxxx

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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