UbixOS V2  2.0
sched.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2002-2018 The UbixOS Project.
3  * All rights reserved.
4  *
5  * This was developed by Christopher W. Olsen for the UbixOS Project.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted
8  * provided that the following conditions are met:
9  *
10  * 1) Redistributions of source code must retain the above copyright notice, this list of
11  * conditions, the following disclaimer and the list of authors.
12  * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13  * conditions, the following disclaimer and the list of authors in the documentation and/or
14  * other materials provided with the distribution.
15  * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16  * endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _UBIXOS_SCHED_H
30 #define _UBIXOS_SCHED_H
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/types.h>
37 #include <vfs/file.h>
38 #include <ubixos/tty.h>
39 
40 #include <sys/tss.h>
41 #include <sys/thread.h>
42 
43 #define NO_GROUP -1
44 #define NR_GROUPS 32
45 
46 typedef enum {
47  PLACEHOLDER = -2, DEAD = -1, NEW = 0, READY = 1, RUNNING = 2, IDLE = 3, FORK = 4, WAIT = 5, UNINTERRUPTIBLE = 6, INTERRUPTIBLE = 7
48 } tState;
49 
50 struct osInfo {
53  bool v86If;
57  char *stdin;
58  char cwd[1024]; /* current working dir */
60 };
61 
62 typedef struct taskStruct {
64  char name[256];
65  struct taskStruct *prev;
66  struct taskStruct *next;
67  struct tssStruct tss;
68  struct i387Struct i387;
69  struct osInfo oInfo;
70  //fileDescriptor *imageFd;
78  struct thread td;
79  struct {
80  struct inode *pwd;
81  struct inode *root;
82  struct inode *exec;
83  } inodes;
88  uint32_t children; // Hack for WAIT
89  uint32_t last_exit; // Hack For WAIT
90  struct taskStruct *parent;
91  char username[256];
92 } kTask_t;
93 
94 int sched_init();
99 void sched_yield();
100 void sched();
101 
102 void schedEndTask(pidType pid);
105 
106 extern kTask_t *_current;
107 extern kTask_t *_usedMath;
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 
114 #endif
taskStruct
Definition: sched.h:62
taskStruct::euid
uint16_t euid
Definition: sched.h:74
schedEndTask
void schedEndTask(pidType pid)
Definition: sched.c:228
NR_GROUPS
#define NR_GROUPS
Definition: sched.h:44
uInt32
unsigned long int uInt32
Definition: objgfx30.h:49
kTask_t
struct taskStruct kTask_t
file.h
sched_setStatus
int sched_setStatus(pidType, tState)
Definition: sched.c:265
uInt16
unsigned short int uInt16
Definition: objgfx30.h:48
fileDescriptor
Definition: file.h:62
NEW
Definition: sched.h:47
schedNewTask
kTask_t * schedNewTask()
Definition: sched.c:135
taskStruct::prev
struct taskStruct * prev
Definition: sched.h:65
taskStruct::username
char username[256]
Definition: sched.h:91
thread
Definition: thread.h:40
schedFindTask
kTask_t * schedFindTask(uInt32 id)
Definition: sched.c:207
taskStruct::counter
uint32_t counter
Definition: sched.h:84
_usedMath
kTask_t * _usedMath
Definition: sched.c:51
RUNNING
Definition: sched.h:47
IDLE
Definition: sched.h:47
taskStruct::tss
struct tssStruct tss
Definition: sched.h:67
taskStruct::ppid
pidType ppid
Definition: sched.h:86
FORK
Definition: sched.h:47
osInfo::stdinSize
uInt32 stdinSize
Definition: sched.h:55
types.h
osInfo::v86If
bool v86If
Definition: sched.h:53
MAX_OFILES
#define MAX_OFILES
Definition: file.h:53
osInfo
Definition: sched.h:50
taskStruct::td
struct thread td
Definition: sched.h:78
osInfo::vmStart
uInt32 vmStart
Definition: sched.h:54
sched_deleteTask
int sched_deleteTask(pidType)
Definition: sched.c:167
tty_termNode
Definition: tty.h:36
uint16_t
__uint16_t uint16_t
Definition: types.h:45
taskStruct::id
pidType id
Definition: sched.h:63
i387Struct
Definition: tss.h:73
_current
kTask_t * _current
Definition: sched.c:50
UNINTERRUPTIBLE
Definition: sched.h:47
sched_init
int sched_init()
Definition: sched.c:66
inode
Definition: inode.h:39
taskStruct::sgid
uint16_t sgid
Definition: sched.h:75
taskStruct::exec
struct inode * exec
Definition: sched.h:82
taskStruct::term
tty_term * term
Definition: sched.h:77
uInt8
unsigned char uInt8
Definition: objgfx30.h:47
taskStruct::suid
uint16_t suid
Definition: sched.h:74
taskStruct::files
fileDescriptor_t * files[MAX_OFILES]
Definition: sched.h:71
sched_addDelTask
int sched_addDelTask(kTask_t *)
Definition: sched.c:186
osInfo::controlKeys
uInt32 controlKeys
Definition: sched.h:56
osInfo::timer
uInt8 timer
Definition: sched.h:51
uint32_t
__uint32_t uint32_t
Definition: types.h:46
tty.h
sched_yield
void sched_yield()
Definition: sched.c:244
osInfo::v86Task
uInt8 v86Task
Definition: sched.h:52
tssStruct
Definition: tss.h:34
taskStruct::usedMath
uInt16 usedMath
Definition: sched.h:76
sched
void sched()
Definition: sched.c:80
taskStruct::parent
struct taskStruct * parent
Definition: sched.h:90
WAIT
Definition: sched.h:47
DEAD
Definition: sched.h:47
taskStruct::i387
struct i387Struct i387
Definition: sched.h:68
osInfo::gpf
uint8_t gpf
Definition: sched.h:59
taskStruct::next
struct taskStruct * next
Definition: sched.h:66
taskStruct::name
char name[256]
Definition: sched.h:64
PLACEHOLDER
Definition: sched.h:47
taskStruct::egid
uint16_t egid
Definition: sched.h:75
pidType
int pidType
Definition: types.h:75
taskStruct::uid
uint32_t uid
Definition: sched.h:73
taskStruct::groups
uint16_t groups[32]
Definition: sched.h:85
taskStruct::pgrp
uint32_t pgrp
Definition: sched.h:87
taskStruct::state
tState state
Definition: sched.h:72
taskStruct::last_exit
uint32_t last_exit
Definition: sched.h:89
taskStruct::pwd
struct inode * pwd
Definition: sched.h:80
READY
Definition: sched.h:47
taskStruct::children
uint32_t children
Definition: sched.h:88
uint8_t
__uint8_t uint8_t
Definition: types.h:44
taskStruct::root
struct inode * root
Definition: sched.h:81
osInfo::stdin
char * stdin
Definition: sched.h:57
thread.h
INTERRUPTIBLE
Definition: sched.h:47
tss.h
taskStruct::oInfo
struct osInfo oInfo
Definition: sched.h:69
osInfo::cwd
char cwd[1024]
Definition: sched.h:58
taskStruct::inodes
struct taskStruct::@20 inodes
tState
tState
Definition: sched.h:46
sched_getDelTask
kTask_t * sched_getDelTask()
Definition: sched.c:195
taskStruct::gid
uint32_t gid
Definition: sched.h:73