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.

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:
ioprio.h source
ioprint_set manual

Similar Posts

  • |

    How to test whether a given path is a directory or a file in C++?

    How to test whether a given path is a directory or a file in C++? For example, pathtype(“/”) –> “a dir” pathtype(“/tmp/file.txt”) –> “a file” # if there is a file file.txt pathtype(“/tmp/dir.txt”) –> “a dir” # if there is a dir named dir.txt The type of a file/dir can be found out using lstat()…

  • |

    How to Install, Run and Uninstall VMware Player and VirtualBox on Fedora Linux

    VMware Player and VirtualBox are two cool and free full virtualization solutions and both can run on top of a Linux host. In this post, I introduce how to install, run, and uninstall VMware Player and VirtualBox on Fedora Linux. VMware Player Install VMware Player Download the installation bundle from VMware’s website. For example, the…

  • Micosoft招聘部分算法题

    Micosoft招聘部分算法题 1.链表和数组的区别在哪里? 2.编写实现链表排序的一种算法。说明为什么你会选择用这样的方法? 3.编写实现数组排序的一种算法。说明为什么你会选择用这样的方法? 4.请编写能直接实现strstr()函数功能的代码。 5.编写反转字符串的程序,要求优化速度、优化空间。 6.在链表里如何发现循环链接? 7.给出洗牌的一个算法,并将洗好的牌存储在一个整形数组里。 8.写一个函数,检查字符是否是整数,如果是,返回其整数值。(或者:怎样只用4行代码编写出一个从字符串到长整形的函数?) 9.给出一个函数来输出一个字符串的所有排列。 10.请编写实现malloc()内存分配函数功能一样的代码。 11.给出一个函数来复制两个字符串A和B。字符串A的后几个字节和字符串B的前几个字节重叠。 12.怎样编写一个程序,把一个有序整数数组放到二叉树中? 13.怎样从顶部开始逐层打印二叉树结点数据?请编程。 14.怎样把一个链表掉个顺序(也就是反序,注意链表的边界条件并考虑空链表)? 来源:·日月光华 bbs.fudan.edu.cn Read more: How to Connect to MySQL in JSP 一个非常优秀的MFC Grid控件 Vim Indenting C/C++ Code GNU glibc Manual How to Generate and Apply Patches using diff and patch on Linux C++ Reference and Styles Push and Pull data…

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *