Sunday, June 25th 2017, 9:12am UTC+2

You are not logged in.

  • Login
  • Register



Date of registration: Aug 9th 2010

Posts: 3


Monday, August 9th 2010, 10:50pm

OS Locks

Dear Segger,

The OS interface of embFile requires me to provide an implementation of several functions for providing lock synchronization. In my setup the function FS_X_OS_Init(unsigned NumLocks) is always called with NumLocks = 0. Changing the value of FS_OS_LOCKING does not have any effect on this. Also, the comments associated with the function states that "FS_NUM_LOCKS" number of binary semaphores/mutexes should be initialized and reserved for embFile. The symbol "FS_NUM_LOCKS", however, is not known to my compiler and I have not been able to locate it in the source.

I should point out that synchronization seems to work fine but I need to "guess" the number of locks needed or allocate them as needed. Neither of those approaches is really satiafactory for our purpose.

Thank you for a very nice and easy to use product,



Super Moderator

Date of registration: Dec 18th 2007

Posts: 1,505


Tuesday, August 10th 2010, 3:57pm

Hi Peter,

the comment in the OS layer template is incorrect.
The value of NumLocks is calculated automatically.

It depends on the compile time switch FS_OS_LOCKING:

If it is not defined, NumLocks is 0
If it is defined to 0, NumLocks is 0
If it is defined to 1, NumLocks is 1
If it is defined to 2, NumLocks is 1 + number of drivers which are added in FS_X_AddDevices()

We will correct this in the template.

Best regards