Open System Services Programmer's Guide

Table 63 Thread-Aware Enscribe Functions (continued)
DescriptionFunction
Sets device-dependent functionsSPT_SETMODE
Writes data to a file from an array in the application, then waits for data to be
transferred back from the file
SPT_WRITEREADX
Writes data from an array in the application to an open fileSPT_WRITEX
Transfers data from an array in the application to a fileSPT_WRITEUPDATEX
Performs random processing of records in a disk fileSPT_WRITEUPDATEUNLOCKX
Excludes other users from accessing a fileSPT_LOCKFILE
Unlocks a disk file and any records in that file currently locked by the userSPT_UNLOCKFILE
Excludes other users from accessing a record at the current positionSPT_LOCKREC
Unlocks a record currently locked by the userSPT_UNLOCKREC
Using Thread-Aware Enscribe Functions
Example 83 (page 378) shows an example of using the thread-aware SPT_FILE_OPEN_. This function
blocks the calling thread instead of the calling process.
Compilation:
/usr/bin/c89 -Wextensions -Wsystype=oss -c ens_thread.c -o ens_thread.o
nld /usr/lib/crtlmain.o ens_thread.o libspt.a -obey /usr/lib/libc.obey
-lzcplsrl -o ens_thread
Output:
Hello, I am in Thread1
Calling SPT_FILE_OPEN_ - thread-blocking Enscribe call
Hello, I am Thread2
error returned in open : 0 filenum : 6
error in file close 0
In contrast, if you replace the calls to the thread-blocking SPT_FILE_OPEN_ function with calls
to the process-blocking FILE_OPEN_ function, and change the printf() statement accordingly,
the program results in the following output:
Hello, I am in Thread1
Calling FILE_OPEN_ - process-blocking Enscribe call
error returned in open : 0 filenum : 6
error in file close 0
Hello, I am Thread2
Thread-Aware Enscribe Functions 377