示例#1
0
// runs processes in queue
bool run_processes(node_t** head, int priority)
{

    bool check_priority = priority >= 0;
    node_t* curr_node = *head;
    proc* currproc;
    while(curr_node)
    {
        if(!check_priority || curr_node->process.priority == priority)
        {
            // get it
            currproc = &curr_node->process;



            // run it
            if(launch_process_as_child(currproc))
            {
                // child shouldn't spawn more children
                fprintf(stderr, "Error: pid %d reached this pointfor some reason\n", getpid());
                return false;
            }


            printf("[%d]process name '%s' priority %d pid %d runtime %d\n", getpid(), currproc->name, currproc->priority, currproc->pid, currproc->runtime);
            


            // be rid of it
            free_proc(currproc);
            if(curr_node == *head)
            {
                curr_node = curr_node->next;
                pop(head);
            } else {
                delete_pid(*head, currproc->pid);
                if(curr_node)
                    curr_node = curr_node->next;
            }
        } else {
            curr_node = curr_node->next;
        }

    }



    
    // you never got to be the one in the tank
    return true;
}
示例#2
0
static void
cleanup (void)
{
        delete_pid ();
}