This is a search engine friendly CGI program that outputs help documents.
The LufDoc (Live User Fed Documentation) comment system will be implemented soon.

PSP Help Doc Indexer System

(Version 1.4.1)


PSP - FileShare Unit Reference

Introduction

Procedures and Functions:

Tips and Tricks

Introduction

    Shared file access is a very important topic for both multithreaded and CGI programs. Even a simple hit counter may cause an I/O error (or other danger) when not taking shared access into account. In multithreaded applications, you can use common variables. However, in CGI you need something on the system I/O level. There are no general purpose cross-platform file sharing utilities available elsewhere, so the FileShare unit in PSP attempts to solve this problem by Advisory File Locking flags. It is a bit slower than system API locking, and it needs write access to whole directory - but fileshare is cross-platform, less specific, and therefore more maintainable.

    Advisory means that only fileshare functions understand these locking flags.

There are two kinds of flags:

  1. Writing flags
    These have only one flag for each locked file. Any reading/writing operations are suspended while it exists.
  2. Reading flags
    These are unique for each reading process. Reading operations are allowed while they exist. All writing operations are suspended until all reading flags are cleaned. FileShare also has garbage collector which removes all flags which are more than 3 minutes old. It protects from long time locking after program crashes not having removed the flag.

Tips and Tricks

  • Use these functions to protect your data files.
  • On UNIX make sure your program has write access to whole directory where the target file resides.

PSP Help documents