XINU
system
ptcount.c
Go to the documentation of this file.
1
5
#include <
xinu.h
>
6
25
int32
ptcount
(
int32
portid)
26
{
27
intmask
mask;
/* Saved interrupt mask */
28
int32
count;
/* Count of messages available */
29
int32
sndcnt;
/* Count of sender semaphore */
30
struct
ptentry
*ptptr;
/* Pointer to port table entry */
31
32
mask =
disable
();
33
if
(
isbadport
(portid) ||
34
(ptptr = &
porttab
[portid])->
ptstate
!=
PT_ALLOC
)
35
{
36
restore
(mask);
37
return
SYSERR
;
38
}
39
40
/* Get count of messages available */
41
42
count =
semcount
(ptptr->
ptrsem
);
43
44
/* If messages are waiting, check for blocked senders */
45
46
if
(count >= 0)
47
{
48
sndcnt =
semcount
(ptptr->
ptssem
);
49
if
(sndcnt < 0)
50
{
/* -sndcnt senders blocked */
51
count += -sndcnt;
52
}
53
}
54
restore
(mask);
55
return
count;
56
}
semcount
syscall semcount(sid32)
セマフォのカウント値を返す。
Definition:
semcount.c:18
restore
void restore(intmask)
ptentry
ポートテーブルエントリ
Definition:
ports.h:33
isbadport
#define isbadport(portid)
ポートIDが不正値かどうかを確認する。
Definition:
ports.h:64
xinu.h
全てのシステムヘッダファイルをインクルードする。
SYSERR
#define SYSERR
処理が失敗した場合
Definition:
kernel.h:79
PT_ALLOC
#define PT_ALLOC
ポートが割り当てられた
Definition:
ports.h:15
ptentry::ptrsem
sid32 ptrsem
受信側セマフォ
Definition:
ports.h:38
porttab
struct ptentry porttab[]
ポートテーブルエントリのextern宣言
Definition:
ptinit.c:10
ptentry::ptssem
sid32 ptssem
送信側セマフォ
Definition:
ports.h:36
ptentry::ptstate
uint16 ptstate
ポート状態(FREE/LIMBO/ALLOC)
Definition:
ports.h:40
intmask
uint32 intmask
保存された割り込みマスク
Definition:
kernel.h:38
int32
int int32
符号あり32ビット整数(int)
Definition:
kernel.h:11
ptcount
int32 ptcount(int32 portid)
ポートを用いたメッセージ送受信において、メッセージ数を数える。
Definition:
ptcount.c:25
disable
intmask disable(void)
割り込み禁止(intr.Sに定義がある)
Generated by
1.8.13