Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

#ifndef __HLP_H__
#define __HLP_H__

#include <kernel/model.h>
#include <kernel/descr.h>
#include "ll/sys/cdefs.h"

__BEGIN_DECLS

#define HLP_RCLASS   0x0600
#define HLP2_RCLASS  0x0700

/* -----------------------------------------------------------------------
   HLP_RES_MODEL: Stack Resource Policy resource model
   ----------------------------------------------------------------------- */


typedef struct {
  RES_MODEL r;
  DWORD preempt;  /* the preemption level of a task */
} HLP_RES_MODEL;

#define HLP_res_default_model(res, pre) \
                                 res_default_model((res).r, HLP_RCLASS); \
                                 (res).preempt = (pre)

#define HLP_res_def_level(res,l) res_def_level(res,l)




/* -----------------------------------------------------------------------
   HLP_mutexattr_t: Higher Locker Priority Mutex Attribute
   ----------------------------------------------------------------------- */

#define HLP_MCLASS      0x0700

#define HLP_MUTEXATTR_INITIALIZER {HLP_MCLASS}
#define HLP_mutexattr_default(a)  mutexattr_default(a, HLP_MCLASS)


RLEVEL HLP_register_module(void);

extern __inline__ RES_MODEL *HLP_usemutex(mutex_t *m) {
  return (RES_MODEL *)m->opt;
};


#define XHLP_INVALID_LOCK 12


typedef mutexattr_t HLP_mutexattr_t;

#define HLP_MUTEXATTR_INITIALIZER {HLP_MCLASS}
#define HLP_mutexattr_default(a)  mutexattr_default(a, HLP_MCLASS)


typedef struct HLP_mutexstruct_t HLP_mutex_t;
typedef struct HLP_taskliststruct_t HLP_tasklist_t;

/* this is the structure normally pointed by the opt field in the
   mutex_t structure */

struct HLP_mutexstruct_t {
  RES_MODEL r;  /*+ This little trick make possible the use of
                    HLP_usemutex                                +*/


  PID owner; /* process that owns the mutex, else nil */
 
  HLP_tasklist_t *tasklist; /* process list that can use(locking or not)
                             the mutex, ordered by preemption
                             level */


  struct HLP_mutexstruct_t *next; /* next mutex of the list */

};

struct HLP_taskliststruct_t {

  PID pid;

  DWORD preempt; /* preemption level */

  HLP_mutex_t *mutexlist; /* list of mutexes */

  HLP_tasklist_t *next; /* next task handled by HLP */
  HLP_tasklist_t *prev; /* prev task handled by HLP */

};

/* The HLP resource level descriptor */
typedef struct {
  mutex_resource_des m;   /*+ the mutex interface +*/

  HLP_mutex_t *mutexlist;     /*+ an unordered list of all created HLP
                                mutexes +*/


  HLP_tasklist_t *tasklist;    /*+ An ordered list by preemption level
                                of all task handled by HLP +*/


} HLP_mutex_resource_des;

__END_DECLS
#endif