-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest4.c
More file actions
55 lines (44 loc) · 986 Bytes
/
test4.c
File metadata and controls
55 lines (44 loc) · 986 Bytes
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
#include <stdio.h>
#include <stdlib.h>
#include <threads.h>
#include <terminals.h>
#include <unistd.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()
{
InitTerminalDriver();
InitTerminal(1);
for (int i = 0; i < 4; i++) {
ThreadCreate(writer1, NULL);
ThreadCreate(writer2, NULL);
}
ThreadWaitAll();
while(1) sleep(10);
exit(0);
}
void
writer1(void *arg)
{
int status;
(void)arg;
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;
(void)arg;
status = WriteTerminal(1, string2, length2);
if (status != length2)
fprintf(stderr, "Error: writer2 status = %d, length2 = %d\n",
status, length2);
}