-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsrv.c
64 lines (47 loc) · 1.11 KB
/
srv.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
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Phoenix-RTOS
*
* libphoenix
*
* POSIX server - standalone main
*
* Copyright 2018, 2023 Phoenix Systems
* Author: Jan Sikorski, Gerard Swiderski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/msg.h>
#include <sys/threads.h>
#include "posixsrv_private.h"
#include "posixsrv.h"
static char stacks[4][0x1000] __attribute__((aligned(8)));
static int fail(const char *str)
{
printf("posixsrv fail: %s\n", str);
exit(EXIT_FAILURE);
}
int main(int argc, char **argv)
{
oid_t fs;
unsigned srvPort;
unsigned eventPort;
while (lookup("/", NULL, &fs) < 0) {
usleep(5000);
}
if (posixsrv_init(&srvPort, &eventPort) < 0) {
fail("srv init");
}
openlog("posixsrv", LOG_CONS, LOG_DAEMON);
beginthread(posixsrv_threadMain, 4, stacks[0], sizeof(stacks[0]), (void *)(uintptr_t)eventPort);
for (int i = 1; i < sizeof(stacks) / sizeof(stacks[0]); ++i) {
beginthread(posixsrv_threadMain, 4, stacks[i], sizeof(stacks[i]), (void *)(uintptr_t)srvPort);
}
posixsrv_threadRqTimeout(NULL);
/* never reached */
return 0;
}