source: buchla-68k/orig/MT/MTID.C@ cbe2c15

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

Imported original source code.

  • Property mode set to 100755
File size: 1.6 KB
Line 
1/*
2 =============================================================================
3 mtid.c -- Multi-Tasker -- get next task ID
4 Version 1 -- 1988-04-11 -- 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#include "debug.h"
13
14extern short setipl(); /* set processor IPL function */
15
16extern struct _mtdef *_MT_; /* Multi-Tasker structure pointer */
17
18/*
19
20*/
21
22/*
23 =============================================================================
24 MTID() -- return next available task identifier
25 =============================================================================
26*/
27
28unsigned
29MTID()
30{
31 register short inuse, oldipl;
32 register unsigned newtid;
33 register TCB *tcp;
34
35 inuse = TRUE; /* preset inuse to get things started */
36
37 if ((struct _mt_def *)NIL EQ _MT_)
38 _MT_ = (struct _mt_def *)XBIOS(X_MTDEFS);
39
40 oldipl = setipl(7); /* DISABLE INTERRUPTS */
41
42 while (inuse) {
43
44 newtid = _MT_->mtp->IDct++; /* pick the next ID to try */
45 inuse = FALSE; /* say it's not in use */
46 tcp = _MT_->mtp->TCBs; /* start search at beginning */
47
48 while (tcp) { /* search the TCB table */
49
50 if (tcp->flags & MTF_OCC) /* TCB occupied ? */
51 if (tcp->tid EQ newtid) { /* tid in use ? */
52
53 inuse = TRUE; /* set to search again */
54 break;
55 }
56
57 tcp = tcp->fwd;
58 }
59 }
60
61 setipl(oldipl); /* RESTORE INTERRUPTS */
62
63 return(newtid); /* return the new task ID */
64}
Note: See TracBrowser for help on using the repository browser.