XINU
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
sleep.c File Reference
#include <xinu.h>
Include dependency graph for sleep.c:

Go to the source code of this file.

Macros

#define MAXSECONDS   2147483 /* Max seconds per 32-bit msec */
 

Functions

syscall sleep (int32 delay)
 
syscall sleepms (int32 delay)
 

Macro Definition Documentation

◆ MAXSECONDS

#define MAXSECONDS   2147483 /* Max seconds per 32-bit msec */

Definition at line 5 of file sleep.c.

Referenced by sleep().

Function Documentation

◆ sleep()

syscall sleep ( int32  delay)

Definition at line 11 of file sleep.c.

References MAXSECONDS, OK, sleepms(), and SYSERR.

Referenced by xsh_sleep().

14 {
15  if ( (delay < 0) || (delay > MAXSECONDS) ) {
16  return SYSERR;
17  }
18  sleepms(1000*delay);
19  return OK;
20 }
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
#define OK
処理が成功した場合
Definition: kernel.h:77
int32 delay(int n)
マイクロ秒単位で処理を遅らせる。
Definition: initialize.c:262
#define MAXSECONDS
Definition: sleep.c:5
syscall sleepms(int32 delay)
Definition: sleep.c:26
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sleepms()

syscall sleepms ( int32  delay)

Definition at line 26 of file sleep.c.

References currpid, disable(), insertd(), OK, PR_SLEEP, proctab, procent::prstate, resched(), restore(), sleepq, SYSERR, and yield().

Referenced by main(), and sleep().

29 {
30  intmask mask; /* Saved interrupt mask */
31 
32  if (delay < 0) {
33  return SYSERR;
34  }
35 
36  if (delay == 0) {
37  yield();
38  return OK;
39  }
40 
41  /* Delay calling process */
42 
43  mask = disable();
44  if (insertd(currpid, sleepq, delay) == SYSERR) {
45  restore(mask);
46  return SYSERR;
47  }
48 
50  resched();
51  restore(mask);
52  return OK;
53 }
pid32 currpid
現在実行中のプロセス。
Definition: initialize.c:32
void restore(intmask)
qid16 sleepq
スリープ中のプロセスキュー
Definition: clkinit.c:7
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
#define OK
処理が成功した場合
Definition: kernel.h:77
status insertd(pid32, qid16, int32)
Definition: insertd.c:9
syscall yield(void)
CPU実行権を自発的に放棄する(タイムスライスを終了する)。
Definition: yield.c:12
#define PR_SLEEP
プロセスが休眠中(タイマー待機中)の状態。
Definition: process.h:43
uint32 intmask
保存された割り込みマスク
Definition: kernel.h:38
int32 delay(int n)
マイクロ秒単位で処理を遅らせる。
Definition: initialize.c:262
uint16 prstate
プロセス状態(PR_CURR, ..., etc)。
Definition: process.h:88
void resched(void)
最優先の適切なプロセスにCPU実行権を渡す。
Definition: resched.c:22
struct procent proctab[]
プロセステーブル。
Definition: initialize.c:23
intmask disable(void)
割り込み禁止(intr.Sに定義がある)
Here is the call graph for this function:
Here is the caller graph for this function: