/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos72Q src/bos/kernel/sys/extendio.h 1.5.1.1                           */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* Restricted Materials of IBM                                            */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2005,2019              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)91       1.5.1.1  src/bos/kernel/sys/extendio.h, sysios, bos72Q, q2019_13A4 2/6/19 00:43:02 */

#ifndef _H_EXTENDIO
#define _H_EXTENDIO

#include <sys/types.h>  /* pid_t */

#ifdef __cplusplus
extern "C" {
#endif

/* The following type represents an extended buffer cache
 * hint. This is defined as a signed short to allow using
 * negative values to denote failure.  Acceptable values 
 * defined below.
 */
typedef signed short cache_hint_t;

/* Acceptable values for cache_hint_t */
#define CH_AGE_OUT_FAST         0x0010
#define CH_PAGE_WRITE           0x0020

/* The following type represents an I/O priority. Acceptable
 * values are defined in the range of 0 to 15. This is defined
 * as a signed short to allow associated functions to also
 * return the same type for stylistic consistency. -1 will be
 * returned from those functions in case of an error, and thus
 * this typedef must be signed.
 */
typedef signed short iopri_t;

/* Extended buffer I/O priority.  This is either unset (0)
 * or an iopri_t value from 1 and 15.  A lower number value 
 * indicates a higher I/O scheduling priority.  1 would 
 * therefore be the top scheduling priority (ie most 
 * important) and 15 would be the bottom scheduling 
 * priority (ie least important).  
 * 
 * I/O priority can be set on a per-I/O basis through aio, 
 * per-thread basis using the pthreads API functions
 * pthread_setiopri_np/pthread_getiopri_np, on a 
 * per-process basis through setiopri/getiopri interfaces 
 * described below, on a per-class basis using WLM.
 */
#define IOPRIORITY_UNSET        0
#define IOPRIORITY_MIN          IOPRIORITY_UNSET
#define IOPRIORITY_MAX          15
#define IOPRIORITY_MASK		0xF

/* 
 * KGETIOPRI_FINAL is a wrapper macro that allows passing in the per-I/O
 * priority as an argument. If it is not IOPRIORITY_UNSET, then it will
 * in turn call kgetiopri_final.
 */
extern iopri_t kgetiopri_final(void);
#define KGETIOPRI_FINAL(_iopri)                 \
        ((_iopri) != IOPRIORITY_UNSET ? (_iopri) : kgetiopri_final())


/* The following system calls provide the interface for 
 * getting and setting I/O priority on a per-process 
 * basis.  
 */
#ifdef _NO_PROTO

iopri_t setiopri();
iopri_t getiopri();

#else  /* _NO_PROTO */

iopri_t setiopri(pid_t, iopri_t);
iopri_t getiopri(pid_t);

#endif /* _NO_PROTO */

#ifdef __cplusplus
}
#endif

#endif /* _H_EXTENDIO */
