jobs.c
changeset 9 9acd8ae3190c
parent 8 03339adb7014
child 18 af4898956964
equal deleted inserted replaced
8:03339adb7014 9:9acd8ae3190c
    95 void s_removejob(int jobid)
    95 void s_removejob(int jobid)
    96 {
    96 {
    97     struct Job *p;
    97     struct Job *p;
    98     struct Job *newnext;
    98     struct Job *newnext;
    99 
    99 
   100     printf("Remove job %i\n", jobid);
       
   101     if (firstjob->jobid == jobid)
   100     if (firstjob->jobid == jobid)
   102     {
   101     {
   103         struct Job *newfirst;
   102         struct Job *newfirst;
   104         /* First job is to be removed */
   103         /* First job is to be removed */
   105         newfirst = firstjob->next;
   104         newfirst = firstjob->next;
   129 {
   128 {
   130     if (state == WAITING)
   129     if (state == WAITING)
   131         return -1;
   130         return -1;
   132 
   131 
   133     if (firstjob != 0)
   132     if (firstjob != 0)
       
   133     {
       
   134         state = WAITING;
   134         return firstjob->jobid;
   135         return firstjob->jobid;
       
   136     }
   135 
   137 
   136     return -1;
   138     return -1;
   137 }
   139 }
   138 
   140 
   139 void job_finished()
   141 void job_finished()
   140 {
   142 {
   141     struct Job *newfirst;
   143     struct Job *newfirst;
   142 
   144 
   143     assert(state == WAITING);
   145     assert(state == WAITING);
   144     assert(firstjob != 0);
   146     assert(firstjob != 0);
   145     fprintf(stderr, "s: Job %i finished.\n", firstjob->jobid);
       
   146 
   147 
   147     newfirst = firstjob->next;
   148     newfirst = firstjob->next;
   148     free(firstjob);
   149     free(firstjob);
   149     firstjob = newfirst;
   150     firstjob = newfirst;
   150 
   151