作业控制程序 LibChildControl

码农软件 · 软件分类 · 作业/任务调度 · 2019-09-04 23:43:27

软件介绍

LibChildControl 能创建一个线程来管理子进程,并且在失败的时候重启他们。

使用示例:

int child_process (void *data)
{
    int id = *(int *)data;
    int delay = (id + 1) * 1000;

    printf ("TEST: Start child %d.\n", id);

    int i;
    for (i = 0; i < nb_loops; i++) {

        printf ("TEST: Child %d is working (loop %d/%d)\n", id, i + 1, nb_loops);

        int j;
        float r = 0;
        for (j = 0; j < 100 * id; j++) {
            float x = 0;
            do
                x = (float) rand () / ((float)RAND_MAX + 1);
            while (x == 0);
            float y = (float) rand () / ((float)RAND_MAX + 1);
            float z = sqrtf (-2. * logf (x)) * cosf (2 * M_PI * y);
            r += z * (1 << 31);
            usleep (1000);
        }
    }
    
    kill (getpid (), SIGTERM);

    return 0;
}


int child_term (void *data)
{
    int id = *(int *)data;
    printf ("TEST: Child %d is dieing.\n", id);
    return 0;
}

#define nb_children 2
#define nb_loops    10

int main (int argc, char *argv[])
{
    int d[nb_children];
    int i;
    for (i = 0; i < nb_children; i++) {
        d[i] = i + 1;
        register_child (i + 1, NULL, NULL, child_process, child_term, (void *)(d + i));
    }

    sleep (100);

    return 0;
}

本文地址:https://www.codercto.com/soft/d/13899.html

21天学通C语言

21天学通C语言

(美国)琼斯(Bradley L.Jones) (美国)埃特肯(Peter Aitken) / 信达工作室 / 人民邮电出版社 / 2012-8 / 69.00元

《21天学通C语言(第6版•修订版)》是初学者学习C语言的经典教程。本版按最新的标准(ISO∕IEC:9899-1999),以循序渐进的方式介绍了C语言编程方面知识,并提供了丰富的实例和大量的练习。通过学习实例,并将所学的知识用于完成练习,读者将逐步了解、熟悉并精通C语言。《21天学通C语言(第6版•修订版)》包括四周的课程。第一周的课程介绍了C语言程序的基本元素,包括变量、常量、语句、表达式、函......一起来看看 《21天学通C语言》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

html转js在线工具
html转js在线工具

html转js在线工具