Exemplo n.º 1
0
Arquivo: TASK1.C Projeto: jeske/GTalk
void kill_task(int id)          /* this kills a task */
{
  int loop;
#ifdef DEBUG
  char s[80];
#endif


  free_semaphores(id);
  g_free_all_handles(id);
  disable();

  if (id==tswitch)
    unlock_dos();

  if (tasks[id].status)         /* kill only if we're alive */
   {
    tasks[id].status = DEAD;    /* mark status as DEAD */
    tasks[id].paused = 0;       /* mark task as NOT paused */
    tasks[id].who_paused_me=-1;
#ifdef DEBUG
    sprintf(s,"Free memory %p",tasks[id].stck);
    direct_screen(2,0,0x17,s);
    sprintf(s,"%p",*((char *)tasks[id].stck-4));
    direct_screen(2,40,0x17,s);
#endif
    g_free_from_who(tasks[id].stck,id);    /* free our stack memory */
    numTasksOpen--;             /* let tasker know there's one less task */
    if (id == tswitch) switchTasks = 1;  /* if the current task is dead, */
   };                                    /* make sure we switch */
   /* ALSO: make sure any tasks we paused get restarted */

   for (loop=0;loop<MAX_THREADS;loop++)
     if (who_paused(loop)==id)
             unpause(loop);


  enable();
  next_task();                  /* just in case we're the dead task */
};
Exemplo n.º 2
0
void free_common_ressources(void)
{
    free_semaphores(0);
    free_shared(0);
}
Exemplo n.º 3
0
void free_common_ressources_owner(void)
{
    free_semaphores(1);
    free_shared(1);
}