XINU
unsleep.c
Go to the documentation of this file.
1 /* unsleep.c - unsleep */
2 
3 #include <xinu.h>
4 
5 /*------------------------------------------------------------------------
6  * unsleep - Internal function to remove a process from the sleep
7  * queue prematurely. The caller must adjust the delay
8  * of successive processes.
9  *------------------------------------------------------------------------
10  */
12  pid32 pid /* ID of process to remove */
13  )
14 {
15  intmask mask; /* Saved interrupt mask */
16  struct procent *prptr; /* Ptr to process's table entry */
17 
18  pid32 pidnext; /* ID of process on sleep queue */
19  /* that follows the process */
20  /* which is being removed */
21 
22  mask = disable();
23 
24  if (isbadpid(pid)) {
25  restore(mask);
26  return SYSERR;
27  }
28 
29  /* Verify that candidate process is on the sleep queue */
30 
31  prptr = &proctab[pid];
32  if ((prptr->prstate!=PR_SLEEP) && (prptr->prstate!=PR_RECTIM)) {
33  restore(mask);
34  return SYSERR;
35  }
36 
37  /* Increment delay of next process if such a process exists */
38 
39  pidnext = queuetab[pid].qnext;
40  if (pidnext < NPROC) {
41  queuetab[pidnext].qkey += queuetab[pid].qkey;
42  }
43 
44  getitem(pid); /* Unlink process from queue */
45  restore(mask);
46  return OK;
47 }
struct qentry queuetab[]
Definition: queue.c:45
#define PR_RECTIM
プロセスが「タイムアウト」か「メッセージの到着」のいずれか早い方で待機中の状態。
Definition: process.h:49
void restore(intmask)
全てのシステムヘッダファイルをインクルードする。
#define isbadpid(x)
プロセスIDを検証する。割り込みが無効になっている事を想定している。
Definition: process.h:71
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
status unsleep(pid32 pid)
Definition: unsleep.c:11
#define OK
処理が成功した場合
Definition: kernel.h:77
int32 status
ステータスを意味する返り値の型(OK/SYSERR)
Definition: kernel.h:57
qid16 qnext
次のプロセスか末尾のプロセスのインデックス。
Definition: queue.h:39
int32 qkey
キュー順序を決定するキー(優先度)。
Definition: queue.h:37
#define PR_SLEEP
プロセスが休眠中(タイマー待機中)の状態。
Definition: process.h:43
#define NPROC
Definition: conf.h:79
uint32 intmask
保存された割り込みマスク
Definition: kernel.h:38
uint16 prstate
プロセス状態(PR_CURR, ..., etc)。
Definition: process.h:88
pid32 getitem(pid32)
キューの任意の位置からプロセスを取り出す。
Definition: getitem.c:51
struct procent proctab[]
プロセステーブル。
Definition: initialize.c:23
int32 pid32
プロセスID
Definition: kernel.h:26
プロセステーブル(32bitsの倍数)。
Definition: process.h:85
intmask disable(void)
割り込み禁止(intr.Sに定義がある)