| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- provide advice to file system
#include <sys/types.h>#include <sys/fcntl.h>intdirectio(intfildes,intadvice);
Thedirectio() function provides advice to the system about the expected behaviorof the application when accessing the data in the file associated withthe open file descriptorfildes. The system uses this information to helpoptimize accesses to the file's data. Thedirectio() function has no effecton the semantics of the other operations on the data, though itmay affect the performance of other operations.
Theadvice argument is kept per file; the last caller ofdirectio()sets theadvice for all applications using the file associated withfildes.
Values foradvice are defined in<sys/fcntl.h>.
Applications get the default system behavior when accessing file data.
When an application reads data from a file, the data is first cached in system memory and then copied into the application's buffer (seeread(2)). If the system detects that the application is reading sequentially from a file, the system will asynchronously "read ahead" from the file into system memory so the data is immediately available for the nextread(2) operation.
When an application writes data into a file, the data is first cached in system memory and is written to the device at a later time (seewrite(2)). When possible, the system increases the performance ofwrite(2) operations by cacheing the data in memory pages. The data is copied into system memory and thewrite(2) operation returns immediately to the application. The data is later written asynchronously to the device. When possible, the cached data is "clustered" into large chunks and written to the device in a single write operation.
The system behavior forDIRECTIO_OFF can change without notice.
The system behaves as though the application is not going to reuse the file data in the near future. In other words, the file data is not cached in the system's memory pages.
When possible, data is read or written directly between the application's memory and the device when the data is accessed withread(2) andwrite(2) operations. When such transfers are not possible, the system switches back to the default behavior, but just for that operation. In general, the transfer is possible when the application's buffer is aligned on a two-byte (short) boundary, the offset into the file is on a device sector boundary, and the size of the operation is a multiple of device sectors.
This advisory is ignored while the file associated withfildes is mapped (seemmap(2)).
The system behavior forDIRECTIO_ON can change without notice.
Upon successful completion,directio() returns0. Otherwise, it returns-1 and setserrno to indicate the error.
Thedirectio() function will fail if:
Thefildes argument is not a valid open file descriptor.
Thefildes argument is not associated with a file system that accepts advisory functions.
The value inadvice is invalid.
Small sequential I/O generally performs best withDIRECTIO_OFF.
Large sequential I/O generally performs best withDIRECTIO_ON, except when afile is sparse or is being extended and is opened withO_SYNCorO_DSYNC (seeopen(2)).
Thedirectio() function is supported for the NFS and UFS file systemtypes (seefstyp(1M)).
Seeattributes(5) for descriptions of the following attributes:
|
fstyp(1M),mmap(2),open(2),read(2),write(2),fcntl.h(3HEAD),attributes(5)
Switching betweenDIRECTIO_OFF andDIRECTIO_ON can slow the system becauseeach switch toDIRECTIO_ON might entail flushing the file's data from thesystem's memory.
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |