File open/close.
Detailed Description
Cpfspd opens a file at its first access. When the application attempts to open more than 10 files simultaneously, the least recently used one is closed. At program termination, all open files are closed. Normally, this is all handled automatically and the application does not need to take action.
Only in specific cases, the following functions are required. These functions allow more detailed control over the open files.
The open file administration is kept inside the cpfspd library and is stored in global data. Therefore, multithreading applications need to take special precautions.
In a multi threading application one of the following two approaches must be followed: 1) First open all files in a single thread, then start threads to process the data from the opened files. More precise:
- all open and close operations shall be performed in a single thread
- a single file shall be accessed only within a single thread
- no more than 10 files shall be accessed 2) Perform all accesses to a file in a single threat and protect all file open and close operations as critical sections. More precise:
- all open and close operations shall be sequentialized by putting them in a critical section (e.g. guarded by a single semaphore)
- a single file shall be accessed only within a single thread
- no more than 10 files shall be accessed
File open: specify the filename and a flag indicating write access. File close: if a filename is specified, only that file is closed (if it was open); if NULL is specified, all open files are closed.
Function Documentation
pT_status p_open_file |
( |
const char * |
filename, |
|
|
int |
write |
|
) |
|
|
pT_status p_close_file |
( |
const char * |
filename |
) |
|
|
Generated on Thu Nov 19 16:28:20 2009 for cpfspd by
1.3.9.1