XINU
Functions
unsleep.c File Reference
#include <xinu.h>
Include dependency graph for unsleep.c:

Go to the source code of this file.

Functions

status unsleep (pid32 pid)
 

Function Documentation

◆ unsleep()

status unsleep ( pid32  pid)

Definition at line 11 of file unsleep.c.

References disable(), getitem(), isbadpid, NPROC, OK, PR_RECTIM, PR_SLEEP, proctab, procent::prstate, qentry::qkey, qentry::qnext, queuetab, restore(), and SYSERR.

Referenced by kill(), and send().

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
#define OK
処理が成功した場合
Definition: kernel.h:77
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に定義がある)
Here is the call graph for this function:
Here is the caller graph for this function: