Пример #1
0
/* Procedure executed by sideline threads.
 * XXX i#500: Cannot use libc routines (printf) in the child process.
 */
int run(void *arg)
{
    int threadnum = (int)(long) arg;
    int i = 0;
    /* for CLONE_CHILD_CLEARTID for signaling parent.  if we used raw
     * clone system call we could get kernel to do this for us. 
     */
    child[threadnum] = nolibc_syscall(SYS_gettid, 0);
    nolibc_syscall(SYS_set_tid_address, 1, &child[threadnum]);
    child_started[threadnum] = true;
    nolibc_print("Sideline thread started\n");
    while (true) {
        /* do nothing for now */
        i++;
        if (i % 25000000 == 0)
            break;
    }
    while (!child_exit[threadnum])
        nolibc_nanosleep(&sleeptime);
    nolibc_print("Sideline thread finished, exiting whole group\n");
    /* We deliberately bring down the whole group.  Note that this is
     * the default on x64 on returning for some reason which seems
     * like a bug in _clone() (xref i#94).
     */
    nolibc_syscall(SYS_exit_group, 0);
    return 0;
}
Пример #2
0
/* Procedure executed by sideline threads
 * XXX i#500: Cannot use libc routines (printf) in the child process.
 */
int run(void *arg)
{
    int i = 0;
    /* for CLONE_CHILD_CLEARTID for signaling parent.  if we used raw
     * clone system call we could get kernel to do this for us. 
     */
    child = nolibc_syscall(SYS_gettid, 0);
    nolibc_syscall(SYS_set_tid_address, 1, &child);
    nolibc_print("Sideline thread started\n");
    while (true) {
        /* do nothing for now */
        i++;
        if (i % 2500000 == 0) {
            nolibc_print("i = ");
            nolibc_print_int(i);
            nolibc_print("\n");
        }
        if (i % 25000000 == 0)
            break;
    }
    while (!child_exit)
        nanosleep(&sleeptime, NULL);
    nolibc_print("Sideline thread finished\n");
    child_done = true;
#ifdef X64
    /* FIXME: returning here invokes SYS_exit_group and takes down the
     * parent...what's up with that?  Xref i#94.
     */
    nolibc_syscall(SYS_exit, 0);
#endif
    return 0;
}