337 Commits

Author SHA1 Message Date
Grissiom
c045281ee2 object: fix module name testing 2014-12-24 12:10:00 +08:00
Grissiom
4bb6c8cf0c module: add !__CC_ARM when test __GNUC__
ARMCC will define __GNUC__ in "GNU mode"(with --gnu command line
option). So iff __GNUC__ && !__CC_ARM is GCC.
2014-12-01 18:54:55 +08:00
Grissiom
8615e2c8e5 kernel/timer: change row_lvl to unsigned
Use signed int as array index is unsecure.
2014-10-14 16:00:42 +08:00
Bernard Xiong
bd6b39cace Update device.c 2014-09-19 14:29:03 +08:00
bernard
3b5c2e2f9f Merge branch 'master' of https://github.com/RT-Thread/rt-thread 2014-09-11 12:55:18 +08:00
bernard
1f3ea02c5a [Kernel] Use stream mode to open console device. 2014-09-11 12:54:05 +08:00
bernard
b23de95ff4 [Kernel] comments clean up. 2014-09-11 12:51:52 +08:00
bernard
ab786679c7 [Kernel] comments clean up. 2014-09-11 12:50:41 +08:00
Grissiom
d4133990b0 kernel/idle: fix rt_thread_idle_excute in high optimization level
The rt_list_isempty has prototype of "int rt_list_isempty(const rt_list_t *l)".
So the compiler has a good reason that the rt_thread_defunct list does
not change within rt_thread_idle_excute thus optimize the "while" loop
into a "if".

So add the volatile qualifier when test against the rt_thread_defunc list.
2014-09-02 17:21:31 +08:00
tcz717
c0629b342e fix:comment spelling mistake
relation=>relocation
2014-08-24 23:46:31 +08:00
Grissiom
b8bf6bef76 kernel: mempool: fix race condition in rt_mp_alloc
When thread wake up from waiting for memory, there is a chance that
there is no memory available in high pressure. So use a loop to check
again. Otherwise, there will be a NULL reference.
2014-08-20 10:16:04 +08:00
bernard
33fed1b167 [Kernel] Better documentation for doxygen. 2014-07-21 06:29:15 +08:00
bernard
4e2a6cc361 [Kernel] The rt_object_find routine can support to find an object inside a module. The usage is: rt_object_find("module_name/object_name"). 2014-07-21 06:28:43 +08:00
Grissiom
30d68a515c src/timer: fix a compile warning 2014-07-16 22:05:02 +08:00
bernard
7a7e3002c8 [Kernel] system does not lock scheduler when invoking soft-timer timeout function. 2014-07-12 15:59:45 +08:00
bernard
1e7b089494 [Kernel] Remove rt_device_init_all implemetation. 2014-07-10 13:34:52 +08:00
bernard
a1766b6c71 Add WEAK definition; 2014-06-26 14:47:53 +08:00
Grissiom
dc366ecf7a device: only increase the ref_count when device is truly opened 2014-06-18 11:16:21 +08:00
Grissiom
a78e42a7c8 [mempool] reset the thread->error before suspending thread
Time out result and other errors is recorded in thread->error. Dirty
error will screw up the error handling code after the thread has been
wake up.
2014-04-16 10:59:33 +08:00
bernard
8bd3e6f6dc [Kernel] Change command line to const parameter and add system() function. 2014-04-02 14:05:15 +08:00
bernard
dbcb4a1ccf [Kernel] declare more APIs in module 2014-03-11 15:44:35 +08:00
bernard
898e0d2f3f [Kernel] stop thread timer when suspend a thread 2014-03-11 14:19:24 +08:00
bernard
31446eab4c [Kernel] application module can support arguments 2014-01-11 16:33:31 +08:00
Grissiom
04f432f47b kernel: let rt_thread_idle_excute loop until there is no dead thread
Out side world is difficult to tell whethere there is dead thread
remaining. If rt_thread_idle_excute only do one cleanup, it's hard to
finish cleanups outside the idle thread. So let is loop and do all the
cleanups in one call.
2013-12-21 11:31:40 +08:00
Grissiom
408ac34bc2 kernel: add rt_critical_level that return the lock count of scheduler
Out side world may be interested in whether the scheduler is locked or
not. Provide an API to tell that.
2013-12-21 11:27:26 +08:00
Grissiom
6d9e793388 kernel: timer: fix compiling bug in d59aa279c37b7 2013-10-19 21:07:14 +08:00
Bernard Xiong
3eac58ce8e Merge pull request #173 from grissiom/new-timer
kernel: use skip list to implement timer list
2013-10-17 15:44:20 -07:00
Bernard Xiong
c29ff6b0ac Merge pull request #161 from aozima/pulls
make sure the device is in STREAM mode when used by rt_kprintf.
2013-10-17 15:43:56 -07:00
Grissiom
b72001fcac kernel: mutex could only be released in thread context
Mutex has the idea of ownership, only the thread which owns the mutex
can release it. So rt_mutex_release could only be called in thread
context.  Add a debug guard to it.
2013-10-14 09:50:18 +08:00
Grissiom
d59aa279c3 kernel: use skip list to implement timer list
Skip list is a "random" data structure that in high possibilities it
would get O(log(N)) time complexity in inserting while the old list get
O(N). Forthermore, when set RT_TIMER_SKIP_LIST_LEVEL to 1, it will just
the same as the old double linked list, both in time and space
complexity.

Benchmarks shows that when RT_TIMER_SKIP_LIST_LEVEL is 3, the average
time of random insertion of new timer is about 2 times faster than the
old timer when there are 100 timers and 3 times faster when there are
200 timers.

However, it restores the deprecated funcion rt_system_timer_init. BSPs
must invoke it upon system startup.
2013-10-12 22:48:29 +08:00
Grissiom
6f71308ef5 kernel: add RT_DEBUG_IN_THREAD_CONTEXT
In thread context means: 1) the scheduler has been started; 2) not in
interrupt context. It is more stronger than RT_DEBUG_NOT_IN_INTERRUPT.
With this commit, you will catch the error on situations like taking
mutex before scheduling instead of crashing on NULL pointer reference.
2013-10-11 22:51:38 +08:00
aozima
cad12ee14e update rt_kprintf: make sure the device is in STREAM mode when used by rt_kprintf. 2013-09-24 15:29:08 +08:00
Grissiom
7b0a3afdf9 kservice: export vsnprintf as rt_vsnprintf
vsnprintf is a common string function that could be used in many places.
Using both vsnprintf in libc and vsnprintf in the RTT could make a
bigger image. Moreover, if newlib is not enabled when compiling with
GCC, referencing vsnprintf will lead to link error:

    .../arm-none-eabi/lib/armv7-ar/thumb/softfp/libc.a(lib_a-sbrkr.o):
    In function `_sbrk_r':
    sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
    collect2: error: ld returned 1 exit status

Using rt_vsnprintf could avoid such problem.
2013-09-23 11:34:13 +08:00
Grissiom
c465bc2c2e rt_event_recv: add a check on the option flag
Either RT_EVENT_FLAG_AND or RT_EVENT_FLAG_OR should be set in the option
flag. If none of them is present, the waiting thread will never be
resumed.
2013-09-14 13:12:23 +08:00
Grissiom
ad17bc2908 fix debug output of scheduler
When print the thread names, we should use "%.*s" instead of bare "%s".
2013-08-19 10:08:11 +08:00
bernard
b96b35613f add mount table 2013-07-22 07:46:10 +08:00
Grissiom
c3a39444da memheap: dont alloc/memcpy when there is next node is enough for realloc
When realloc a bigger space and the next node is free and big enough, we
should directly relocate the next node instead of doing alloc/memcpy.
The new method not only faster in this cases, it would avoid memory
fragment as well.
2013-07-15 11:47:55 +08:00
Bernard Xiong
2c33678aac fix the memory block splitting issue 2013-07-11 16:20:28 +08:00
Grissiom
7bcce9e87f device: add ref_count support
This is a simple work around to the current device stack design. A
ref_count could let different modules to open/close the same device
independently without interfere others in some degree.

But there is still some data shared between the modules, like flag,
open_flag and user_data. Moreover, it won't yield an error if A open a
device, and B read from it before open it in B. Maybe alloc a new handle
in rt_device_open will be the ultimate solution. But that is much bigger
change and we may leave it to future development.
2013-07-09 15:44:55 +08:00
yiyue.fang
86db9ed965 reformat the coding style
convert Tabs to spaces
2013-06-29 10:00:14 +08:00
Bernard Xiong
79392bb082 Embedded GPLv2 license. 2013-06-24 17:06:09 +08:00
Bernard Xiong
b23dd15990 Update kservice.c 2013-06-24 00:09:52 +08:00
Bernard Xiong
98c8a23e94 Add component initialization. 2013-06-23 07:48:42 +08:00
Bernard Xiong
d80a471680 Fix the memheap_realloc issue 2013-06-03 06:44:35 +08:00
Bernard Xiong
4afdf44da2 add RT_KERNEL_MALLOC/FREE 2013-04-25 14:22:07 +08:00
Bernard Xiong
608bf2cb3d add rt_memheap_realloc function 2013-04-17 22:09:48 +08:00
yiyue.fang
bdeb0e501f update the version information
2006 - 2013 Copyright by rt-thread team
2013-04-10 03:58:33 +08:00
Bernard Xiong
1abaa0492d implement __rt_ffs in kernel service library 2013-03-23 11:27:29 +08:00
Grissiom
0001344105 more deterministic on timer
If two timer will timeout at the same tick, the one started later will
be called later. I've tested the patch on simulator and it _seems_ OK.

Reported-by: xdzy on the forum and delin17 <delin17@qq.com>
2013-01-17 16:13:01 +08:00
Bernard Xiong
72782e9203 convert end of line 2013-01-08 05:05:02 -08:00