z/OS UNIX System Services File System Interface Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Select/poll processing

z/OS UNIX System Services File System Interface Reference
SA23-2285-00

An application program calls select() or poll() with a list of file descriptors and the events that are to be waited for. The file descriptors can represent files, sockets, pipes, or terminals; they are all referred to as "files" in this discussion. The events that can be waited for are: ready for reading, ready for writing, and exceptional conditions. Because a poll() is converted into a select() call by the time the request reaches the PFS, for this discussion only select will be discussed.

There are two operations that can be called to handle the select request: vfs_batsel and vn_select. The vfs_batsel operation is useful for a performance boost; it does not have to be supported. If a PFS supports the vfs_batsel operation, a single call is made to that PFS with an array of information about its files. If a single descriptor is requested, or the PFS does not support vfs_batsel, the vn_select operation is called for the owning PFS for each file specified.

The LFS converts the file descriptors into vnodes. If the user has multiple file descriptors in the list that refer to the same file, such as after a dup(), or if a particular PFS owns more than one file that is present in the list, it receives a separate call for each file if the vfs_batsel operation is not supported. Otherwise, a single call is made with multiple array entries for the same file. While one user is waiting in select() for some files, another user may issue select() for some of the same files. The LFS manages the lists and the associations of users to requests. The PFS should just treat each vn_select or vfs_batsel array entry as a completely separate and independent action against the file, and be prepared for more than one select() to be active at a time for a file.

Select processing consists of two phases, called Query and Cancel, which are identified by a parameter on the select call. Each file may be called for both phases or just for Cancel. When a user specifies a timeout value of 0, the LFS skips the Query phase and goes right into the Cancel phase.

The LFS passes a select token to the PFS with each vn_select or vfs_batsel array element call. The select token uniquely identifies a request for both phases, and thus can be used by the PFS to correlate Queries and Cancels. This token is unique to this single instance of vn_select(Query) being called, and is not used again until after the corresponding call to vn_select(Cancel).

There is also a PFS_work_token available on vn_select and in each array element of vfs_batsel that can be set by the PFS to correlate Queries and Cancels.
Note: Only vn_select is mentioned in this discussion. The only difference between vn_select and vfs_batsel is that similar processing must occur within a loop for the array elements of the vfs_batsel request.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014