/shark/trunk/include/kernel/func.h |
---|
21,11 → 21,11 |
/** |
------------ |
CVS : $Id: func.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $ |
CVS : $Id: func.h,v 1.2 2002-11-11 08:36:01 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1.1.1 $ |
Last update: $Date: 2002-03-29 14:12:51 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-11-11 08:36:01 $ |
------------ |
Kernel functions: |
89,15 → 89,6 |
/* if a source use printk() it should include log.h not func.h */ |
#include <kernel/log.h> |
#if 0 |
#ifdef __DEBUG_ON__ |
#define printk(fmt,args...) \ |
VM_printf(fmt,##args) |
#else |
#define printk(fmt,args...) |
#endif |
#endif |
/*---------------------------------------------------------------------*/ |
/* Kernel global functions: initialization & termination... */ |
/*---------------------------------------------------------------------*/ |
145,7 → 136,7 |
int set_exchandler_text(); |
/*---------------------------------------------------------------------*/ |
/* Kernel global functions: scheduler, queues */ |
/* Kernel global functions: scheduler, */ |
/*---------------------------------------------------------------------*/ |
/*+ This is the generic scheduler. |
157,26 → 148,6 |
the end of an event list +*/ |
void event_need_reschedule(); |
/* Simple QUEUE management functions */ |
void q_insert (PID p, QUEUE *q); |
void q_timespec_insert (PID p, QUEUE *q); |
void q_extract (PID p, QUEUE *q); |
PID q_getfirst ( QUEUE *q); |
void q_insertfirst (PID p, QUEUE *q); |
/* QQUEUE management functions */ |
void qq_init ( QQUEUE *q); |
void qq_insert (PID p, QQUEUE *q); |
void qq_timespec_insert (PID p, QQUEUE *q); |
void qq_extract (PID p, QQUEUE *q); |
PID qq_getfirst ( QQUEUE *q); |
void qq_insertfirst (PID p, QQUEUE *q); |
void qq_insertlast (PID p, QQUEUE *q); |
PID qq_queryfirst ( QQUEUE *q); |
PID qq_querylast ( QQUEUE *q); |
void task_makefree(void *ret); |
void check_killed_async(void); |
221,15 → 192,6 |
return ll_context_from(); |
} |
#ifdef __TEST1__ |
extern int useds; |
extern int testactive; |
extern struct timespec s_send[]; |
#endif |
/*+ this functions are called every time a context is changed +*/ |
void kern_after_dispatch(void); |
243,10 → 205,6 |
{ |
ll_context_to(c); |
kern_after_dispatch(); |
#ifdef __TEST1__ |
if (testactive) ll_gettime(TIME_EXACT,&s_send[useds-1] ); |
#endif |
sti(); |
} |
539,9 → 497,6 |
Pending activations are discarded +*/ |
void task_sleep(void); |
/*+ This function suspend the actual task for a minimum delay time +*/ |
void task_delay(DWORD delay); |
/*+ This primitives refers the group id which is supplied |
by the application, not by the kernel +*/ |
int group_activate(WORD g); |
/shark/trunk/include/kernel/iqueue.h |
---|
0,0 → 1,197 |
/* |
* 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: iqueue.h,v 1.1 2002-11-11 08:36:01 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1 $ |
Last update: $Date: 2002-11-11 08:36:01 $ |
------------ |
*/ |
/* |
* Copyright (C) 2002 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 |
* |
*/ |
/* |
IQUEUEs |
This file contains functions that helps to manage task queues. |
These functions are different from the functions that manages the |
QUEUE and QQUEUE types. In particular, these functions no more relies |
on the prev & next fields of the task descriptor. In that way, tasks |
can be inserted in more than one queue at a time. |
Basically, an IQUEUE has an "I"nternal prev/next structure, that may |
be shared between one or more queue. Of course, the user MUST |
guarantee that the same task will not be inserted in two IQUEUEs that |
share the same prev/next buffer. |
The queue insertion is made by the following functions: |
iq_insert -> insertion based on the priority field. |
iq_timespec_insert -> same as above but use the timespec_priority field |
iq_insertfirst -> insert in the first position of the queue |
*/ |
#include <ll/ll.h> |
#include <kernel/const.h> |
#include <kernel/types.h> |
#ifndef __KERNEL_IQUEUE_H__ |
#define __KERNEL_IQUEUE_H__ |
#define IQUEUE_NO_PRIORITY 1 |
#define IQUEUE_NO_TIMESPEC 2 |
struct IQUEUE_shared { |
PID prev[MAX_PROC]; |
PID next[MAX_PROC]; |
struct timespec *timespec_priority; |
DWORD *priority; |
}; |
typedef struct { |
PID first; |
PID last; |
struct IQUEUE_shared *s; |
} IQUEUE; |
/* Internal queue initialization: |
share = &x -> the internal data structure of the IQUEUE x is used |
to enqueue the tasks. |
share = NULL -> an internal data structure to handle prev/next |
pairs is dynamically allocated (The amount of |
memory that is allocated can be reduced using the |
flags). |
flags can be used to reduce the memory usage of an IQUEUE when share=NULL: |
IQUEUE_NO_PRIORITY -> the iqueue do not provide internally a priority field |
IQUEUE_NO_TIMESPEC -> the iqueue do not provide internally a timespec field |
- note that, if these flags are used, the corresponding insert |
functions will not work! |
- the default value for the flags is, of course, 0 |
*/ |
void iq_init (IQUEUE *q, IQUEUE *share, int flags); |
/* Queue insert functions: |
- inserts a p into the q. p must not be already inserted into q. |
- four versions of the function; |
- iq_priority_insert -> ordered insertion using the priority field |
- iq_timespec_insert -> ordered insertion using the timespec field |
- iq_insertfirst -> insert at the first position of the queue |
- iq_insertlast -> insert at the last position of the queue |
*/ |
void iq_priority_insert (PID p, IQUEUE *q); |
void iq_timespec_insert (PID p, IQUEUE *q); |
void iq_insertfirst (PID p, IQUEUE *q); |
void iq_insertlast (PID p, IQUEUE *q); |
/* Queue extract functions: |
- extracts a task p from the queue q. |
- three versions of the function; |
- iq_extract -> extracts given a task p |
(that must be inserted in the queue) |
- iq_getfirst -> extracts the first task in the queue, |
NIL if the queue is empty |
- iq_getlast -> extracts the last task in the queue, |
NIL if the queue is empty |
*/ |
void iq_extract (PID p, IQUEUE *q); |
PID iq_getfirst ( IQUEUE *q); |
PID iq_getlast ( IQUEUE *q); |
/* Queue query functions: |
The first two functions return the first and the last task in the queue, |
NIL if the queue is empty. |
The second two functions can be used to get/set the priority or the |
timespec field used when queuing. |
*/ |
static __inline__ PID iq_query_first(IQUEUE *q) |
{ |
return q->first; |
} |
static __inline__ PID iq_query_last(IQUEUE *q) |
{ |
return q->last; |
} |
static __inline__ struct timespec *iq_query_timespec(PID p, IQUEUE *q) |
{ |
return &q->s->timespec_priority[p]; |
} |
static __inline__ DWORD *iq_query_priority (PID p, IQUEUE *q) |
{ |
return &q->s->priority[p]; |
} |
/* Queue iterators */ |
/* sometimes it is useful to go through the list. For that reason |
You can use the following two functions... */ |
static __inline__ PID iq_query_next (PID p, IQUEUE *q) |
{ |
return q->s->next[p]; |
} |
static __inline__ PID iq_query_prev (PID p, IQUEUE *q) |
{ |
return q->s->prev[p]; |
} |
/* Queue test functions */ |
static __inline__ int iq_isempty (IQUEUE *q) |
{ |
return q->first == NIL; |
} |
#endif |
/shark/trunk/include/kernel/int_sem.h |
---|
21,11 → 21,11 |
/** |
------------ |
CVS : $Id: int_sem.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $ |
CVS : $Id: int_sem.h,v 1.2 2002-11-11 08:36:01 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1.1.1 $ |
Last update: $Date: 2002-03-29 14:12:51 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-11-11 08:36:01 $ |
------------ |
Internal semaphores. |
63,12 → 63,13 |
#define __INT_SEM_H__ |
#include <kernel/types.h> |
#include <kernel/iqueue.h> |
/* this is the structure normally pointed by the opt field in the |
mutex_t structure */ |
typedef struct { |
int count; |
QQUEUE blocked; |
IQUEUE blocked; |
} internal_sem_t; |
/shark/trunk/include/kernel/kern.h |
---|
21,11 → 21,11 |
/** |
------------ |
CVS : $Id: kern.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $ |
CVS : $Id: kern.h,v 1.2 2002-11-11 08:36:01 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1.1.1 $ |
Last update: $Date: 2002-03-29 14:12:51 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-11-11 08:36:01 $ |
------------ |
Main kernel include file. |
67,6 → 67,8 |
//#include <kernel/err.h> |
//#include <kernel/exc.h> |
#include <kernel/var.h> |
#include <kernel/iqueue.h> |
#include <kernel/func.h> |
/shark/trunk/include/kernel/descr.h |
---|
21,11 → 21,11 |
/** |
------------ |
CVS : $Id: descr.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $ |
CVS : $Id: descr.h,v 1.2 2002-11-11 08:36:01 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1.1.1 $ |
Last update: $Date: 2002-03-29 14:12:51 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-11-11 08:36:01 $ |
------------ |
Kernel main data structures |
70,6 → 70,7 |
#include <ll/ll.h> |
#include <kernel/model.h> |
#include <kernel/types.h> |
#include <kernel/iqueue.h> |
#include <limits.h> |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
140,8 → 141,8 |
struct _task_handler_rec *cleanup_stack; |
/*+ The cleanup stack +*/ |
QUEUE next,prev; /*+ Next/Prev Index in the queue +*/ |
int errnumber; |
/* Job Execution Time fields */ |
174,8 → 175,7 |
* the generic kernel, with exclusion of delay_timer that is used |
* also in cond_timedwait |
*/ |
DWORD priority; /*+ A priority field +*/ |
struct timespec timespec_priority; /*+ Another priority field +*/ |
int delay_timer; /*+ A field useful to store the delay timer +*/ |
int wcet; /*+ a worst case time execution +*/ |
219,8 → 219,6 |
0 if the level can manage the model, |
-1 if not +*/ |
// void (*level_init)(); /*+ initialization of the level module +*/ |
// void (*level_end)(); /*+ level termination (at system end... +*/ |
void (*level_status)(LEVEL l);/*+ print level statistics... +*/ |
PID (*level_scheduler)(LEVEL l); |
286,9 → 284,6 |
task in the EXE state. +*/ |
void (*task_delay)(LEVEL l, PID p,DWORD tickdelay); |
/* guest CALLS: |
these functions are called from an Aperiodic Server Level for the task |
that are inserted in the local queues */ |
324,7 → 319,6 |
/*+ the task is killed +*/ |
void (*guest_sleep)(LEVEL l, PID p); |
void (*guest_delay)(LEVEL l, PID p, TIME tickdelay); |
} level_des; |
438,7 → 432,7 |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
typedef struct condition_struct { |
QUEUE waiters; /*+ queue for tasks waiting on the condition +*/ |
IQUEUE waiters; /*+ queue for tasks waiting on the condition +*/ |
mutex_t *used_for_waiting; |
} cond_t; |
/shark/trunk/include/kernel/types.h |
---|
21,11 → 21,11 |
/** |
------------ |
CVS : $Id: types.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $ |
CVS : $Id: types.h,v 1.2 2002-11-11 08:36:01 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1.1.1 $ |
Last update: $Date: 2002-03-29 14:12:51 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-11-11 08:36:01 $ |
------------ |
**/ |
49,27 → 49,9 |
* |
*/ |
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
HARTIK SYSTEM TYPES |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ |
#ifndef __KERNEL_TYPES_H__ |
#define __KERNEL_TYPES_H__ |
/*+ Used to manage task queues +*/ |
typedef int QUEUE; |
/*+ Used to manage task queues with tail +*/ |
typedef struct { |
int first; /*+ first element of a task queue, NIL if empty +*/ |
int last; /*+ last element of a task qqueue, NIL if empty +*/ |
} QQUEUE; |
/*+ Used to manage mutex queues +*/ |
//typedef int MQUEUE; |
#define TASK void * |
/*+ ... a task index +*/ |
/shark/trunk/include/kernel/config.h |
---|
21,11 → 21,11 |
/** |
------------ |
CVS : $Id: config.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $ |
CVS : $Id: config.h,v 1.2 2002-11-11 08:36:01 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1.1.1 $ |
Last update: $Date: 2002-03-29 14:12:51 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-11-11 08:36:01 $ |
------------ |
Kernel configuration macros: |
57,28 → 57,6 |
#ifndef __KERNEL_CONFIG_H__ |
#define __KERNEL_CONFIG_H__ |
/*+ Define this if you use the CABs... +*/ |
#define __CAB__ |
/*+ Define this if you use the ports... +*/ |
#define __PORT__ |
/*+ Define this if you use the tracer... +*/ |
#define __TRACE__ |
//#undef __TRACE__ |
/*+ Define this if you want the printk messages... +*/ |
#define __DEBUG_ON__ |
#undef __DEBUG_ON__ |
/*+ checks the Memory at the kern_mem_init... +*/ |
#undef __MEM_DEBUG__ |
/*+ defined if we are compiling test1.c with init1.c +*/ |
//#define __TEST1__ |
/*+ defined if we are compiling testG.c +*/ |
//#define TESTG |
/shark/trunk/include/kernel/var.h |
---|
21,11 → 21,11 |
/** |
------------ |
CVS : $Id: var.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $ |
CVS : $Id: var.h,v 1.2 2002-11-11 08:36:01 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.1.1.1 $ |
Last update: $Date: 2002-03-29 14:12:51 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-11-11 08:36:01 $ |
------------ |
Kernel global variables |
70,7 → 70,7 |
extern PID exec; /*+ task suggested by the scheduler +*/ |
extern PID exec_shadow; /*+ task really executed +*/ |
extern QUEUE freedesc; /*+ Free descriptor handled as a queue +*/ |
extern IQUEUE freedesc; /*+ Free descriptor handled as a queue +*/ |
extern TIME sys_tick; /*+ System tick (in usec) +*/ |
extern struct timespec schedule_time; |