ReactOS 0.4.16-dev-258-g81860b4
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 305 of file sys_arch.c.

306{
309
311
313
315 NULL,
316 NULL,
317 0,
318 sizeof(struct lwip_callback_msg),
320 0);
321
323 NULL,
324 NULL,
325 0,
326 sizeof(QUEUE_ENTRY),
328 0);
329}
#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:13
KEVENT TerminationEvent
Definition: sys_arch.c:9
NPAGED_LOOKASIDE_LIST MessageLookasideList
Definition: sys_arch.c:10
NPAGED_LOOKASIDE_LIST QueueEntryLookasideList
Definition: sys_arch.c:11
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:72
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
Definition: sys_arch.c:86
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
Definition: sys_arch.c:46
#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 275 of file sys_arch.c.

276{
277 thread_t Container;
279
280 Container = ExAllocatePool(NonPagedPool, sizeof(*Container));
281 if (!Container)
282 return 0;
283
284 Container->ThreadFunction = thread;
285 Container->ThreadContext = arg;
286
287 Status = PsCreateSystemThread(&Container->Handle,
289 NULL,
290 NULL,
291 NULL,
293 Container);
294
295 if (!NT_SUCCESS(Status))
296 {
297 ExFreePool(Container);
298 return 0;
299 }
300
301 return 0;
302}
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:256
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
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:18
void * ThreadContext
Definition: sys_arch.c:19
HANDLE Handle
Definition: sys_arch.c:17
void * arg
Definition: msvc.h:10

Referenced by slipif_init(), and tcpip_init().