Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/* Project:     OSLib
2
 * Description: The OS Construction Kit
3
 * Date:                1.6.2000
4
 * Idea by:             Luca Abeni & Gerardo Lamastra
5
 *
6
 * OSLib is an SO project aimed at developing a common, easy-to-use
7
 * low-level infrastructure for developing OS kernels and Embedded
8
 * Applications; it partially derives from the HARTIK project but it
9
 * currently is independently developed.
10
 *
11
 * OSLib is distributed under GPL License, and some of its code has
12
 * been derived from the Linux kernel source; also some important
13
 * ideas come from studying the DJGPP go32 extender.
14
 *
15
 * We acknowledge the Linux Community, Free Software Foundation,
16
 * D.J. Delorie and all the other developers who believe in the
17
 * freedom of software and ideas.
18
 *
19
 * For legalese, check out the included GPL license.
20
 */
21
 
22
#include <stdlib.h>
23
#include <stdio.h>
24
#include <hw-data.h>
25
#include "event.h"
26
 
27
FILE(Event - Stub);
28
 
29
extern struct event *freeevents;
30
extern struct event *firstevent;
31
extern TIME actTime;
32
 
33
 
34
void called(void)
35
{
36
    printf("Called...\n");
37
}
38
 
39
void event_printqueue(struct event *q)
40
{
41
    struct event *p;
42
 
43
    for (p = q; p; p = p->next) {
44
        printf("Entry %d: Time %d...\n", p->index, p->time);
45
    }
46
}
47
 
48
main()
49
{
50
    int i, rem;
51
    event_init();
52
 
53
    printf("Free event queue:\n");
54
    event_printqueue(freeevents);
55
    printf("Pending events queue:\n");
56
    event_printqueue(firstevent);
57
 
58
    i = event_post(10, called, NULL);
59
    printf("Inserted Event %d\n", i);
60
 
61
    printf("Free event queue:\n");
62
    event_printqueue(freeevents);
63
    printf("Pending events queue:\n");
64
    event_printqueue(firstevent);
65
 
66
    i = event_post(100, called, NULL);
67
    printf("Inserted Event %d\n", i);
68
 
69
    i = event_post(5, called, NULL);
70
    printf("Inserted Event %d\n", i);
71
    i = event_post(50, called, NULL);
72
    printf("Inserted Event %d\n", i);
73
    i = event_post(1, called, NULL);
74
    printf("Inserted Event %d\n", i);
75
    i = event_post(110, called, NULL);
76
    printf("Inserted Event %d\n", i);
77
 
78
    printf("Pending events queue:\n");
79
    event_printqueue(firstevent);
80
 
81
    printf("Now, Wakin' up...\n");
82
 
83
    actTime = 1;
84
    wake_up(10);
85
    printf("Pending events queue:\n");
86
    event_printqueue(firstevent);
87
 
88
    actTime = 70;
89
    wake_up(10);
90
    i = event_post(45, called, NULL);
91
    i = event_post(80, called, NULL);
92
    i = event_post(20, called, NULL);
93
    rem = event_post(90, called, NULL);
94
    i = event_post(105, called, NULL);
95
    i = event_post(150, called, NULL);
96
    printf("Pending events queue:\n");
97
    event_printqueue(firstevent);
98
    i = event_delete(rem);
99
    printf("EVT %d removed...OK=%d Pending events queue:\n", rem, i);
100
    event_printqueue(firstevent);
101
    i = event_delete(6);
102
    printf("EVT 6 removed...OK=%d Pending events queue:\n", i);
103
    i = event_delete(2);
104
    printf("EVT 2 removed...OK=%d Pending events queue:\n", i);
105
    i = event_delete(8);
106
    printf("EVT 8 removed...OK=%d Pending events queue:\n", i);
107
    event_printqueue(firstevent);
108
}