1 /*****************************************************************************
2 * FullFAT - High Performance, Thread-Safe Embedded FAT File-System *
3 * Copyright (C) 2009 James Walmsley (james@worm.me.uk) *
5 * This program is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 3 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
20 * Alternative Licensing is available directly from the Copyright holder, *
21 * (James Walmsley). For more information consult LICENSING.TXT to obtain *
22 * a Commercial license. *
24 * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. *
26 * Removing the above notice is illegal and will invalidate this license. *
27 *****************************************************************************
28 * See http://worm.me.uk/fullfat for more information. *
29 * Or http://fullfat.googlecode.com/ for latest releases and the wiki. *
30 *****************************************************************************/
34 * @author James Walmsley
37 * @defgroup SAFETY Process Safety for FullFAT
38 * @brief Provides semaphores, and thread-safety for FullFAT.
40 * This module aims to be as portable as possible. It is necessary to modify
41 * the functions FF_CreateSemaphore, FF_PendSemaphore, FF_ReleaseSemaphore,
42 * and FF_DestroySemaphore, as appropriate for your platform.
44 * If your application has no OS and is therefore single threaded, simply
47 * FF_CreateSemaphore() return NULL.
49 * FF_PendSemaphore() should do nothing.
51 * FF_ReleaseSemaphore() should do nothing.
53 * FF_DestroySemaphore() should do nothing.
57 #include "ff_safety.h" // Íncludes ff_types.h
59 void *FF_CreateSemaphore(void) {
60 // Call your OS's CreateSemaphore function
63 // return pointer to semaphore
64 return NULL
; // Comment this out for your implementation.
67 void FF_PendSemaphore(void *pSemaphore
) {
68 // Call your OS's PendSemaphore with the provided pSemaphore pointer.
70 // This should block indefinitely until the Semaphore
71 // becomes available. (No timeout!)
72 // If your OS doesn't do it for you, you should sleep
73 // this thread until the Semaphore is available.
77 void FF_ReleaseSemaphore(void *pSemaphore
) {
78 // Call your OS's ReleaseSemaphore with the provided pSemaphore pointer.
85 void FF_DestroySemaphore(void *pSemaphore
) {
86 // Call your OS's DestroySemaphore with the provided pSemaphore pointer.
94 // Call your OS's thread Yield function.
95 // If this doesn't work, then a deadlock will occur
98 void FF_Sleep(FF_T_UINT32 TimeMs
) {
99 // Call your OS's thread sleep function,
100 // Sleep for TimeMs milliseconds
106 * Notes on implementation.