ReactOS 0.4.16-dev-1946-g52006dd
Collaboration diagram for Misc:

Functions

void sys_msleep (u32_t ms)
 
sys_thread_t sys_thread_new (const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
 
void sys_init (void)
 

Detailed Description

Function Documentation

◆ sys_init()

void sys_init ( void  )

sys_init() must be called before anything else. Initialize the sys_arch layer.

Definition at line 309 of file sys_arch.c.

310{
313
315
317
319 NULL,
320 NULL,
321 0,
322 sizeof(struct lwip_callback_msg),
324 0);
325
327 NULL,
328 NULL,
329 0,
330 sizeof(QUEUE_ENTRY),
332 0);
333}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
static LIST_ENTRY ThreadListHead
Definition: sys_arch.c:6
static KSPIN_LOCK ThreadListLock
Definition: sys_arch.c:7
static LARGE_INTEGER StartTime
Definition: sys_arch.c:15
KEVENT TerminationEvent
Definition: sys_arch.c:11
NPAGED_LOOKASIDE_LIST MessageLookasideList
Definition: sys_arch.c:12
NPAGED_LOOKASIDE_LIST QueueEntryLookasideList
Definition: sys_arch.c:13
VOID NTAPI ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:218
#define LWIP_MESSAGE_TAG
Definition: lwip_glue.h:11
#define LWIP_QUEUE_TAG
Definition: lwip_glue.h:12
@ NotificationEvent
Definition: lwip_glue.h:18

Referenced by lwip_init().

◆ sys_msleep()

void sys_msleep ( u32_t  ms)

Sleep for specified number of ms

Sleep for some ms. Timeouts are NOT processed while sleeping.

Parameters
msnumber of milliseconds to sleep

Definition at line 135 of file sys.c.

136{
137 if (ms > 0) {
138 sys_sem_t delaysem;
139 err_t err = sys_sem_new(&delaysem, 0);
140 if (err == ERR_OK) {
141 sys_arch_sem_wait(&delaysem, ms);
142 sys_sem_free(&delaysem);
143 }
144 }
145}
s8_t err_t
Definition: err.h:96
@ ERR_OK
Definition: err.h:55
void sys_sem_free(sys_sem_t *sem)
Definition: sys_arch.c:78
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
Definition: sys_arch.c:92
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
Definition: sys_arch.c:52
#define err(...)

◆ sys_thread_new()

sys_thread_t sys_thread_new ( const char name,
lwip_thread_fn  thread,
void arg,
int  stacksize,
int  prio 
)

The only thread function: Starts a new thread named "name" with priority "prio" that will begin its execution in the function "thread()". The "arg" argument will be passed as an argument to the thread() function. The stack size to used for this thread is the "stacksize" parameter. The id of the new thread is returned. Both the id and the priority are system dependent. ATTENTION: although this function returns a value, it MUST NOT FAIL (ports have to assert this!)

Parameters
namehuman-readable name for the thread (used for debugging purposes)
threadthread-function
argparameter passed to 'thread'
stacksizestack size in bytes for the new thread (may be ignored by ports)
priopriority of the new thread (may be ignored by ports)

Definition at line 279 of file sys_arch.c.

280{
281 thread_t Container;
283
284 Container = ExAllocatePool(NonPagedPool, sizeof(*Container));
285 if (!Container)
286 return 0;
287
288 Container->ThreadFunction = thread;
289 Container->ThreadContext = arg;
290
291 Status = PsCreateSystemThread(&Container->Handle,
293 NULL,
294 NULL,
295 NULL,
297 Container);
298
299 if (!NT_SUCCESS(Status))
300 {
301 ExFreePool(Container);
302 return 0;
303 }
304
305 return 0;
306}
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE thread
Definition: service.c:33
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Status
Definition: gdiplustypes.h:25
VOID NTAPI LwipThreadMain(PVOID Context)
Definition: sys_arch.c:260
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1342
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
void(* ThreadFunction)(void *arg)
Definition: sys_arch.c:20
void * ThreadContext
Definition: sys_arch.c:21
HANDLE Handle
Definition: sys_arch.c:19
void * arg
Definition: msvc.h:10

Referenced by slipif_init(), and tcpip_init().