-
Notifications
You must be signed in to change notification settings - Fork 1
/
test4.c
52 lines (40 loc) · 999 Bytes
/
test4.c
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
#include <stdio.h>
#include <stdlib.h>
#include <threads.h>
#include <terminals.h>
void writer1(void *);
void writer2(void *);
char string1[] = "abcdefghijklmnopqrstuvwxyz\n";
int length1 = sizeof(string1) - 1;
char string2[] = "0123456789\n";
int length2 = sizeof(string2) - 1;
int
main(int argc, char **argv)
{
InitTerminalDriver();
InitTerminal(1);
if (argc > 1) HardwareOutputSpeed(1, atoi(argv[1]));
if (argc > 2) HardwareInputSpeed(1, atoi(argv[2]));
ThreadCreate(writer1, NULL);
ThreadCreate(writer2, NULL);
ThreadWaitAll();
exit(0);
}
void
writer1(void *arg)
{
int status;
status = WriteTerminal(1, string1, length1);
if (status != length1)
fprintf(stderr, "Error: writer1 status = %d, length1 = %d\n",
status, length1);
}
void
writer2(void *arg)
{
int status;
status = WriteTerminal(1, string2, length2);
if (status != length2)
fprintf(stderr, "Error: writer2 status = %d, length2 = %d\n",
status, length2);
}