-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
65 lines (58 loc) · 1.24 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*Moj kod*/
#include <iostream.h>
#include "Timer.h"
#include "PCB.h"//testiranje
#include "IVTEntry.h"//testiranje
#include <dos.h>//testiranje
/*Lokovi sa ugnjezdavanjem*/
#define lock() asm{\
pushf;\
cli;\
}
#define unlock() asm popf;
/*Argumenti koje prosljedjujemo userMain-u*/
volatile int argcGlobal;
char** argvGlobal;
volatile int resultGlobal;//Rezultat userMain-a
volatile int globalIP, globalCS;//ne koriste se
unsigned system_sp,system_ss;//SP i SS main() funkcije
int userMain(int, char*[]);
class Thread;
/*Klasa korisnicke niti*/
class UserMain:public Thread
{
public:
void run();
};
void UserMain::run()
{
resultGlobal=userMain(argcGlobal,argvGlobal);
dispatch();
}
/*Klasa prazne niti*/
class IdleThread:public Thread
{
public:
void run();
};
void IdleThread::run()
{
while(1);
}
int main(int argc, char* argv[])
{
argcGlobal=argc;
argvGlobal=argv;
int a;
lock();
/*Deklarisanje prve dvije niti*/
Thread* userMain=new UserMain();
userMain->start();
idleThread=new IdleThread();
idleThread->start();
unlock();
Timer::setISR();//Pocetak prekidnog koda
dispatch();//Prvi dispatch()
Timer::restoreISR();//Kraj prekidnog koda
return resultGlobal;
}