Пример #1
0
int kill(int pid, int sig)
{
#ifndef NDEBUG
  _syscall_printf("\n Syscall kill(%x, %x)", pid, sig);
#endif
  /* errno = EINVAL; */
  /* return -1; */
  int ret = _syscall_kill(pid, sig);
  errno = syscall_errno;
  return ret;
}
/*-------------------------------------------
| Name:_kernel_timer
| Description:
| Parameters:
| Return Type:
| Comments:
| See:
---------------------------------------------*/
void _kernel_timer(void){
   pid_t _pid;
   kill_t kill_dt;

   kernel_pthread_t* pthread_ptr;
   //
   pthread_ptr = g_pthread_lst;
   //
   while(pthread_ptr) {
      if(pthread_ptr
         && (pthread_ptr->pid>0)
         && ((signed long)(pthread_ptr->time_out)>=0L)) {
         //
         if(pthread_ptr->time_out>0L) {
            if( pthread_ptr->time_out-- ) {
               pthread_ptr=pthread_ptr->gnext;
               continue;
            }
         }
         //try make sytem call
         if(__syscall_trylock()==-EBUSY) {
            pthread_ptr=pthread_ptr->gnext;
            continue;
         }
         //prepare to kill pthread
         pthread_ptr->time_out = -1;
         kill_dt.pid = pthread_ptr->pid;
         kill_dt.sig = SIGALRM;
         kill_dt.atomic = 0; //__clrirq(), __setirq() not used.
         //send SIGALRM to pthread
         _syscall_kill(pthread_ptr,pthread_ptr->pid,&kill_dt);
         __set_active_pthread(pthread_ptr);

         //end of sys call
         __syscall_unlock();
      }

      pthread_ptr=pthread_ptr->gnext;
   }

   for(_pid=1; _pid<=PROCESS_MAX; _pid++) {
      if(!process_lst[_pid]) continue;


   }

   rttmr_restart(&kernel_tmr);

}