2 static struct workq_reqthreads_req_s
{unsigned long priority
; int count
;} requests
[REQUESTS_LEN
];
4 #define QOS_STR(q) (q == QOS_CLASS_USER_INTERACTIVE ? "UInter" : (q == QOS_CLASS_USER_INITIATED ? "UInit" : (q == QOS_CLASS_DEFAULT ? "Dflt" : (q == QOS_CLASS_UTILITY ? "Util" : (q == QOS_CLASS_BACKGROUND ? "BG" : "Unkn" ) ) ) ) )
5 static char* describe_pri(pthread_priority_t pri
){
9 qos
= _pthread_qos_class_decode(pri
, NULL
, &flags
);
12 if (flags
& _PTHREAD_PRIORITY_EVENT_MANAGER_FLAG
){
13 sprintf(desc
, "E:%s", QOS_STR(qos
));
14 } else if (flags
& _PTHREAD_PRIORITY_OVERCOMMIT_FLAG
){
15 sprintf(desc
, "O:%s", QOS_STR(qos
));
17 sprintf(desc
, "%s", QOS_STR(qos
));
23 static char* describe_req(void){
24 static char desc
[256];
28 for (int i
= 0; i
< REQUESTS_LEN
; i
++){
30 c
+= sprintf(c
, "{%s,%d}", describe_pri(requests
[i
].priority
), requests
[i
].count
);
38 static char *dummy_text
= "Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the";
39 // takes about 1us on my machine
40 static void burn_cpu(void){
41 char key
[64]; char txt
[64];
42 strncpy(txt
, dummy_text
, 64);
43 for (int i
= 0; i
< 64; i
++)
50 static int do_req(void){
51 int ret
= sysctlbyname("debug.wq_kevent_test", NULL
, NULL
, requests
, sizeof(requests
));
53 fprintf(stderr
, "wq_kevent_test(%s) -> %d\n", describe_req(), ret
);
55 perror("debug.wk_kevent_test");