source: buchla-68k/orig/MT/MTSTAT.C@ c79db87

Last change on this file since c79db87 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 1.9 KB
Line 
1/*
2 =============================================================================
3 mtstat.c -- Multi-Tasker -- task status check
4 Version 4 -- 1988-04-14 -- D.N. Lynx Crowe
5 (c) Copyright 1988 -- D.N. Lynx Crowe
6 =============================================================================
7*/
8
9#include "stddefs.h"
10#include "biosdefs.h"
11#include "mtdefs.h"
12
13extern short setipl(); /* set processor IPL function */
14
15extern struct _mt_def *_MT_;
16
17/*
18
19*/
20
21/*
22 =============================================================================
23 MTStat() -- check task status
24
25 -3 stopped, waiting on a sempahore
26 -2 stopped, not waiting
27 -1 not found
28 0 running (current task)
29 1 ready to run
30 2 waiting on a sempahore
31 =============================================================================
32*/
33
34short
35MTStat(tid)
36unsigned tid;
37{
38 register TCB *tcp;
39 register short oldipl, rv;
40
41/*
42
43*/
44 if ((struct _mt_def *)NIL EQ _MT_)
45 _MT_ = (struct _nt_def *)XBIOS(X_MTDEFS);
46
47 tcp = _MT_->mtp->TCBs; /* point at start of TCB list */
48 rv = -1; /* preset return value */
49
50 oldipl= setipl(7); /* DISABLE INTERRUPTS */
51
52 while (tcp) { /* check each TCB */
53
54 if (tcp->flags & MTF_OCC) { /* occupied ? */
55
56 if (tcp->tid NE tid) /* continue if not tid */
57 goto nexttcb;
58
59 if (tcp->flags & MTF_RUN) { /* running ? */
60
61 rv = 0;
62 break;
63 }
64
65 if (tcp->flags & MTF_RDY) { /* ready to run ? */
66
67 rv = 1;
68 break;
69 }
70
71 if (tcp->flags & MTF_STP) { /* to be stopped ? */
72
73 rv = -3;
74 break;
75 }
76
77 if (tcp->flags & MTF_SWT) { /* waiting ? */
78
79 rv = 2;
80 break;
81 }
82
83 rv = -2; /* stopped */
84 break;
85 }
86
87nexttcb:
88 tcp = tcp->fwd; /* look at next TCB */
89 }
90
91 setipl(oldipl); /* RESTORE INTERRUPTS */
92
93 return(rv); /* return status of task */
94}
95
Note: See TracBrowser for help on using the repository browser.