Choco OS  V.0.16.9.0
Join to the chocolate world
oc_system.c
Go to the documentation of this file.
1 
27 #include <oc_processman.h>
28 #include <oc_threadman.h>
29 #include <oc_clock_lld.h>
30 #include <oc_userman.h>
31 #include <oc_sys_lld.h>
32 
38 #define _________________________________________INTERFACE_FUNCTIONS_SECTION________________________________________________________________
39 
40 Allocator_t getcurallocator(void)
41 {
42  return oC_ProcessMan_GetCurrentAllocator();
43 }
44 
45 Process_t getcurprocess(void)
46 {
47  return oC_ProcessMan_GetCurrentProcess();
48 }
49 
50 User_t getcuruser(void)
51 {
52  return oC_Process_GetUser(oC_ProcessMan_GetCurrentProcess());
53 }
54 
55 bool iscurroot(void)
56 {
57  bool iscurroot = getcuruser() == getrootuser();
58 
59  if(iscurroot == false)
60  {
62  }
63 
64  return iscurroot;
65 }
66 
67 oC_Timestamp_t gettimestamp(void)
68 {
69  return oC_KTime_GetTimestamp();
70 }
71 
72 
73 oC_Time_t gettimeout( oC_Timestamp_t Timestamp )
74 {
75  return oC_KTime_CalculateTimeout(Timestamp);
76 }
77 
78 oC_Timestamp_t timeouttotimestamp( oC_Time_t Timeout )
79 {
80  return oC_KTime_GetTimestamp() + Timeout;
81 }
82 
83 User_t getrootuser(void)
84 {
85  return oC_UserMan_GetRootUser();
86 }
87 
88 Thread_t getcurthread(void)
89 {
90  return oC_ThreadMan_GetCurrentThread();
91 }
92 
93 bool sleep( oC_Time_t Time )
94 {
95  bool slept = false;
96  oC_Thread_t currentThread = oC_ThreadMan_GetCurrentThread();
97 
98  if(oC_Thread_IsCorrect(currentThread))
99  {
100  slept = oC_Thread_Sleep(currentThread,Time);
101  }
102  else
103  {
104  slept = oC_CLOCK_LLD_DelayForMicroseconds(oC_Time_ToMicroseconds(Time));
105  }
106 
107  return slept;
108 }
109 
110 #undef _________________________________________INTERFACE_FUNCTIONS_SECTION________________________________________________________________
oC_SYS_LLD_Context_t * oC_SYS_LLD_GetSystemContext(void)
returns pointer to the system context
Definition: oc_sys_lld.c:408
identifier for allocations
Definition: oc_stdlib.h:159
oC_SYS_LLD_Context_t * oC_SYS_LLD_GetCurrentContext(void)
returns pointer to the current context
Definition: oc_sys_lld.c:397
The file with interface for process manager.
File with interface for user system manager.
Definition: oc_user.c:43
The file with LLD interface for the CLOCK driver.
The file with LLD interface for the SYS driver.
The file with interface for Thread Manager.
bool oC_CLOCK_LLD_DelayForMicroseconds(oC_UInt_t Microseconds)
perform a delay for us
Definition: oc_clock_lld.c:297