Subversion Repositories shark

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

/*
 * Project: S.Ha.R.K.
 *
 * Coordinators:
 *   Giorgio Buttazzo    <giorgio@sssup.it>
 *   Paolo Gai           <pj@gandalf.sssup.it>
 *
 * Authors     :
 *   Paolo Gai           <pj@gandalf.sssup.it>
 *   (see the web pages for full authors list)
 *
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
 *
 * http://www.sssup.it
 * http://retis.sssup.it
 * http://shark.sssup.it
 */


/**
 ------------
 CVS :        $Id: delay.c,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $

 File:        $File$
 Revision:    $Revision: 1.1.1.1 $
 Last update: $Date: 2002-03-29 14:12:51 $
 ------------

 task_delay

**/


/*
 * Copyright (C) 2000 Paolo Gai
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */


#include <stdarg.h>
#include <ll/ll.h>
#include <ll/stdlib.h>
#include <ll/stdio.h>
#include <ll/string.h>
#include <kernel/config.h>
#include <kernel/model.h>
#include <kernel/const.h>
#include <sys/types.h>
#include <kernel/types.h>
#include <kernel/descr.h>
#include <errno.h>
#include <kernel/var.h>
#include <kernel/func.h>
#include <kernel/trace.h>

/*+
  Suspend the task for s time unit
+*/

void task_delay(DWORD usdelay)
{
  LEVEL l;            /* for readableness only */
  TIME tx;            /* a dummy TIME for timespec operations */
  struct timespec ty; /* a dummy timespec for timespec operations */

  /* task_delay is a cancellation point */
  task_testcancel();

  proc_table[exec_shadow].context = kern_context_save();

  /* SAME AS SCHEDULER... manage the capacity event and the load_info */
  ll_gettime(TIME_EXACT, &schedule_time);
  SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty);
  tx = TIMESPEC2USEC(&ty);
  proc_table[exec_shadow].avail_time -= tx;
  jet_update_slice(tx);
  if (cap_timer != NIL) {
    event_delete(cap_timer);
    cap_timer = NIL;
  }

  l = proc_table[exec_shadow].task_level;
  level_table[l]->task_delay(l,exec_shadow, usdelay);

  /* tracer stuff */
  trc_logevent(TRC_DELAY,NULL);

  exec = exec_shadow = -1;
  scheduler();
  kern_context_load(proc_table[exec_shadow].context);

  /* task_delay is a cancellation point */
  task_testcancel();
}