How to use ioprio_set in linux c

Since there is no glibc wrapper for ioprio_set in linux c, we need to call this API with some definition.

asked Jan 12 by harryxiyou (4,840 points)

1 Answer

 
Best answer

Using syscall in linux as follows.

syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, pid, IOPRIO_PRIO_CLASS(IOPRIO_CLASS_IDLE));

Some other definitions to declare above macros.

  69 enum {                                                                                                     
  70     IOPRIO_CLASS_NONE,                                                                                     
  71     IOPRIO_CLASS_RT,                                                                                       
  72     IOPRIO_CLASS_BE,                                                                                       
  73     IOPRIO_CLASS_IDLE,                                                                                     
  74 };                                                                                                         
  75                                                                                                            
  76 enum {                                                                                                     
  77     IOPRIO_WHO_PROCESS = 1,                                                                                
  78     IOPRIO_WHO_PGRP,                                                                                       
  79     IOPRIO_WHO_USER,                                                                                       
  80 };     

  65 #define IOPRIO_CLASS_SHIFT  (13)                                                                           
  66                                                                                                            
  67 #define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT)

References: http://lxr.free-electrons.com/source/include/linux/ioprio.h

answered Jan 12 by harryxiyou (4,840 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...