LibMCore线程管理库
LibMCore 是一个提供各种函数用来创建异步轻量级进程和通用队列处理的 C 开发库。可实现统计核心数、实时调度、设置核心亲和度以及操作循环计数器。
示例代码:
extern void huge_process_init (void);
extern int huge_process (void *_param);
int nb_blocks = 10;
int nb_loops = 100;
/* init structure */
data_t *d = (data_t *) calloc (nb_blocks, sizeof (data_t));
 ...
/* create queue */
queue_task_t *queue = create_queue_task ("process", 1000, 70, 2, "0+1+2+3:2", huge_process_init);
for (j = 0; j < nb_loops; j++) {
    /* fill queue */
    queue_sub_task_info_t *queue_huge_process = queue_init (queue);
    for (i = 0; i < nb_blocks; i++) {
        rc = queue_load (queue, queue_huge_process, huge_process, d + i);
        if (rc == 0)
            printf ("error %d for load %d\n", rc, i);
    }
    /* queue processing */
    rc = queue_end (queue, queue_huge_process);
    if (rc == 0)
        printf ("error %d on queue ending\n", rc);
    /* statistics */
    queue_stat (queue, 1);
    printf ("\n");
}评论
