Skip to content

Commit de30730

Browse files
committed
original files
1 parent 4064070 commit de30730

File tree

5 files changed

+45
-382
lines changed

5 files changed

+45
-382
lines changed

APP77.CPP

Lines changed: 26 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,100 +10,64 @@
1010
// user Functions
1111
void a( )
1212
{
13-
MUTEX.acquire();
13+
SMARTS.contextSwitchOff();
1414
cout << "\n ************* A Start *********************";
15-
MUTEX.release();
16-
for (int j=0; j < 3; j++)
15+
SMARTS.contextSwitchOn();
16+
for (int j=0; j <500; j++)
1717
{
1818
for (long i=0; i <600000; i++);
19-
MUTEX.acquire();
19+
SMARTS.contextSwitchOff();
2020
cout << "A";
21-
MUTEX.release();
21+
SMARTS.contextSwitchOn();
2222
}
23-
MUTEX.acquire();
23+
SMARTS.contextSwitchOff();
2424
cout << "\n ************* A Finish *********************";
25-
MUTEX.release();
25+
SMARTS.contextSwitchOn();
2626
}
2727

2828
void b( )
2929
{
30-
MUTEX.acquire();
30+
SMARTS.contextSwitchOff();
3131
cout << "\n ************* B Start *********************";
32-
MUTEX.release();
33-
for (int j=0; j < 2; j++)
32+
SMARTS.contextSwitchOn();
33+
for (int j=0; j <500; j++)
3434
{
3535
for (long i=0; i < 600000; i++);
36-
MUTEX.acquire();
36+
SMARTS.contextSwitchOff();
3737
cout << "B";
38-
MUTEX.release();
38+
SMARTS.contextSwitchOn();
3939
}
40-
MUTEX.acquire();
40+
SMARTS.contextSwitchOff();
4141
cout << "\n ************* B Finish *********************";
42-
MUTEX.release();
42+
SMARTS.contextSwitchOn();
4343
}
4444

4545
void c( )
4646
{
47-
MUTEX.acquire();
47+
SMARTS.contextSwitchOff();
4848
cout << "\n ************* C Start *********************";
49-
MUTEX.release();
50-
for (int j=0; j <10; j++)
49+
SMARTS.contextSwitchOn();
50+
for (int j=0; j <500; j++)
5151
{
5252
for (long i=0; i < 600000; i++);
53-
MUTEX.acquire();
53+
SMARTS.contextSwitchOff();
5454
cout << "C";
55-
MUTEX.release();
55+
SMARTS.contextSwitchOn();
5656
}
57-
MUTEX.acquire();
57+
SMARTS.contextSwitchOff();
5858
cout << "\n ************* C Finish *********************";
59-
MUTEX.release();
59+
SMARTS.contextSwitchOn();
6060
}
6161

62-
void a1()
63-
{
64-
MUTEX.acquire();
65-
//SMARTS.contextSwitchOff();
66-
cout << "\n A";
67-
for (long i = 0; i < 6000000; i++);
68-
cout << "\n ************* A1 *********************";
69-
MUTEX.release();
70-
//SMARTS.contextSwitchOn();
71-
}
72-
void a2()
73-
{
74-
MUTEX.acquire();
75-
//SMARTS.contextSwitchOff();;
76-
cout << "\n ************* A2 *********************";
77-
MUTEX.release();
78-
//SMARTS.contextSwitchOn();
79-
}
80-
void a3()
81-
{
82-
MUTEX.acquire();
83-
//SMARTS.contextSwitchOff();
84-
cout << "\n ************* A3 *********************";
85-
MUTEX.release();
86-
//SMARTS.contextSwitchOn();
87-
}
88-
89-
90-
9162
void main( )
9263
{
9364
clrscr();
9465
SMARTS.externalFunctions(timerInterruptHandler, scheduler, myTaskEnd, roundRobin);
95-
//SMARTS.declareTask(a,'A', 51, 3, 30);
96-
//SMARTS.declareTask(b,'B', 50, 2, 20);
97-
//SMARTS.declareTask(c,'C', 49, 1, 10);
98-
SMARTS.declareTask(a3, 'c', 102, 2, 3);
99-
SMARTS.declareTask(a1, 'a', 100, 2, 1);
100-
SMARTS.declareTask(a2, 'b', 101, 2, 2);
101-
102-
103-
66+
SMARTS.declareTask(a,'A');
67+
SMARTS.declareTask(b,'B');
68+
SMARTS.declareTask(c,'C');
10469
SMARTS.runTheTasks();
105-
106-
char a;
107-
cin >> a;
10870
}
10971

72+
73+

EXTERN77.CPP

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
/********** GLOBAL Variables **********/
1111
Parallelism SMARTS;
12-
Mutex MUTEX;
1312
static unsigned StackSegAct, StackPtrAct;
1413

1514
/********** EXTERNAL FUNCTION **********/
@@ -27,15 +26,14 @@ void far interrupt timerInterruptHandler(...)
2726
if (!SMARTS.getProgInt( ))
2827
{
2928
asm int userInt;
30-
SMARTS.handleClockPeriods();
3129
SMARTS.handleTimers();
3230
}
3331
else
3432
SMARTS.resetProgInt( ); //else it is a software "prog interrupt". reset this flag
3533

3634
// if the 'context switch' flag=true, save the current task variables
3735
// and call the 'scheduler'
38-
if (SMARTS.getContextSwitch( ) || SMARTS.getProgInt()) // save stack addr of interrupted task in current stack
36+
if (SMARTS.getContextSwitch( )) // save stack addr of interrupted task in current stack
3937
{
4038
SMARTS.setCurrentStack(StackSegAct,StackPtrAct);
4139
SMARTS.restoreSchedStack( ); // prepare activation of the task "scheduler"
@@ -78,9 +76,6 @@ void scheduler( ) // this also a parallel task
7876

7977
// 'dispatcher' to restore the next task stack addr and registers
8078
SMARTS.getCurrentStack(StackSegAct,StackPtrAct);
81-
82-
//cout << "[NEXT-TASK] " << nextTask << " [" << StackSegAct << ":" << StackPtrAct << "]" ;
83-
8479
asm mov ax,StackSegAct;
8580
asm mov ss,ax
8681
asm mov sp,StackPtrAct

0 commit comments

Comments
 (0)