#include <rtl_debug.h>#include <pthread.h>#include "lwip/sys.h"#include "lwip/opt.h"#include "rtl_malloc.h"#include "gettimeofday.h"#include "bcopy.h"#include <rtl_sched.h>#include <rtl_sync.h>#include <rtl_sema.h>#include <rtl.h>#include <time.h>#include <signal.h>Include dependency graph for sys_arch.c:
Go to the source code of this file.
Data Structures | |
| struct | sys_mbox |
| struct | sys_mbox_msg |
| struct | sys_sem |
| struct | sys_thread |
| struct | sys_timeouts |
| struct | thread_start_param |
Defines | |
| #define | AND(a, b) (a & b) |
| #define | SET(a, b) ((b) <= (0xFF) ? (a=(a | b)) : (a=0x00)) |
| #define | MAX_TIMERS 20 |
| #define | MAX_VECTOR_MALLOCS 50 |
| #define | SYS_MBOX_SIZE 100 |
Functions | |
| sys_sem * | sys_sem_new_ (u8_t count) |
| int | sys_sem_post (sem_t *sem) |
| int | sys_sem_signal_pre (struct sys_sem *sem) |
| void | sys_stop_interrupts (unsigned int *state) |
| void | sys_allow_interrupts (unsigned int *state) |
| int | obtain_index_to_free (void *mem) |
| void | free_all_resources (void) |
| void * | sys_malloc (size_t size) |
| void | sys_free (void *ptr) |
| sys_thread * | sys_current_thread (void) |
| sys_thread * | sys_search_thread (void *pthread) |
| void * | thread_start (void *arg) |
| void * | sys_thread_exit (void) |
| int | sys_thread_delete (void *pthread) |
| void | sys_thread_register (void *pthread) |
| void * | sys_thread_new (void(*function)(void *arg), void *arg, unsigned long period) |
| sys_mbox * | sys_mbox_new () |
| void | sys_mbox_free (struct sys_mbox *mbox) |
| void | sys_mbox_post (struct sys_mbox *mbox, void *msg) |
| u16_t | sys_arch_mbox_fetch (struct sys_mbox *mbox, void **msg, u16_t timeout) |
| sys_sem * | sys_sem_new (u8_t count) |
| u16_t | wait_for_semaphore (struct sys_sem *sem, u16_t timeout) |
| u16_t | sys_arch_sem_wait (struct sys_sem *sem, u16_t timeout) |
| int | sys_sem_signal (struct sys_sem *sem) |
| void | sys_sem_free (struct sys_sem *sem) |
| void | sys_arch_close (void) |
| void | sys_init (void) |
| void | sys_sem_wait (sys_sem_t sem) |
| int | sys_sem_wait_timeout (sys_sem_t sem, u32_t timeout) |
| void | sys_mbox_fetch (sys_mbox_t mbox, void **msg) |
| void | sys_timeout (u16_t msecs, sys_timeout_handler h, void *arg) |
| void | sys_untimeout (sys_timeout_handler h, void *arg) |
Variables | |
| sys_thread * | threads = NULL |
| void * | mallocs [MAX_VECTOR_MALLOCS] |
| int | malloc_index = 0 |
| int | n_mallocs = 0 n_frees = 0 |
| sys_timeouts | vector_of_timers [MAX_TIMERS] |
| int | timer_index = 0 |
| int | signal = 0 |
|
|
Definition at line 96 of file sys_arch.c. Referenced by sys_arch_close(), sys_current_thread(), and sys_search_thread(). |
|
|
Definition at line 99 of file sys_arch.c. Referenced by sys_init(). |
|
|
Definition at line 103 of file sys_arch.c. Referenced by free_all_resources(), obtain_index_to_free(), and sys_malloc(). |
|
|
Definition at line 97 of file sys_arch.c. Referenced by sys_current_thread(), sys_search_thread(), sys_thread_delete(), sys_thread_exit(), sys_thread_new(), and sys_thread_register(). |
|
|
Definition at line 127 of file sys_arch.c. Referenced by sys_arch_mbox_fetch(), and sys_mbox_post(). |
|
|
Definition at line 204 of file sys_arch.c. References mallocs, MAX_VECTOR_MALLOCS, NULL, and rtl_free. Referenced by sys_arch_close().
00204 {
00205 int i;
00206
00207 for(i=0; i<MAX_VECTOR_MALLOCS; i++)
00208 if(mallocs[i] != NULL){
00209 rtl_free(mallocs[i]);
00210 n_frees++;
00211 }
00212 }
|
|
|
Definition at line 194 of file sys_arch.c. References mallocs, and MAX_VECTOR_MALLOCS. Referenced by sys_free().
00194 {
00195 int i;
00196
00197 for(i=0; i< MAX_VECTOR_MALLOCS; i++)
00198 if(mallocs[i] == mem)
00199 return i;
00200 return -1;
00201 }
|
|
|
Definition at line 189 of file sys_arch.c. Referenced by pbuf_free(), pbuf_pool_alloc(), pbuf_pool_free(), pbuf_ref(), pbuf_ref_chain(), pbuf_refresh(), sys_free(), sys_malloc(), and sys_mbox_post().
00189 {
00190 rtl_restore_interrupts((rtl_irqstate_t) *state);
00191 }
|
|
|
Definition at line 703 of file sys_arch.c. References AND, free_all_resources(), NULL, sys_free(), and threads. Referenced by rt_3com905cif_low_level_input(), and rt_rtl8139if_low_level_input().
00704 {
00705 struct sys_thread *st;
00706
00707 for(st = threads; st != NULL; st = st->next) {
00708 if(AND(st->flags,0x81)== 0x80){ //i.e. It is a standalone thread finished
00709 sys_free(st->stack);
00710 }else if(AND(st->flags,0xff)==0x00){ //i.e A thread still working
00711 pthread_delete_np(st->pthread);
00712 //This line is necessary because the thread could be standalone.
00713 //If it is not, nothing happens
00714 sys_free(st->stack);
00715 }else if(AND(st->flags,0xff)==0x01){ //i.e A registered thread still working
00716 pthread_cancel(st->pthread);
00717 pthread_join(st->pthread,NULL);
00718 }
00719 }
00720
00721 free_all_resources();
00722
00723 return;
00724 }
|
Here is the call graph for this function:
|
||||||||||||||||
|
Definition at line 547 of file sys_arch.c. References sys_mbox::first, sys_mbox::last, sys_mbox::mail, sys_mbox::msgs, sys_mbox::mutex, NULL, sys_arch_sem_wait(), SYS_MBOX_SIZE, sys_sem_signal(), time, and u16_t.
00548 {
00549 u16_t time = 1;
00550
00551 /* The mutex lock is quick so we don't bother with the timeout
00552 stuff here. */
00553 sys_arch_sem_wait(mbox->mutex, 0);
00554 while(mbox->first == mbox->last) {
00555 sys_sem_signal(mbox->mutex);
00556 /* We block while waiting for a mail to arrive in the mailbox. We
00557 must be prepared to timeout. */
00558 if(timeout != 0) {
00559
00560 time = sys_arch_sem_wait(mbox->mail, timeout);
00561
00562 /* If time == 0, the sem_wait timed out, and we return 0. */
00563 if(time == 0) {
00564 return 0;
00565 }
00566 } else
00567 sys_arch_sem_wait(mbox->mail, 0);
00568
00569 sys_arch_sem_wait(mbox->mutex, 0);
00570 }
00571
00572 if(msg != NULL) {
00573 *msg = mbox->msgs[mbox->first];
00574 }
00575
00576 mbox->first++;
00577 if(mbox->first == SYS_MBOX_SIZE) {
00578 mbox->first = 0;
00579 }
00580
00581 sys_sem_signal(mbox->mutex);
00582
00583 return time;
00584 }
|
Here is the call graph for this function:
|
||||||||||||
|
Definition at line 654 of file sys_arch.c. References sys_sem::c, sys_sem::sem, time, u16_t, and wait_for_semaphore().
00655 {
00656 u16_t time = 1;
00657
00658 sem->sem.value = sem->c;
00659
00660 while(sem->c <= 0) {
00661
00662 if(timeout > 0) {
00663
00664 time = wait_for_semaphore(sem, timeout);
00665 if(time == 0)
00666 return 0;
00667 } else {
00668 wait_for_semaphore(sem,0);
00669 }
00670 }
00671
00672 sem->c--;
00673 sem->sem.value = sem->c;
00674
00675 return time;
00676 }
|
Here is the call graph for this function:
|
|
Definition at line 261 of file sys_arch.c. References AND, NULL, SET, sys_free(), and threads. Referenced by sys_thread_exit(), sys_timeout(), and sys_untimeout().
00262 {
00263 struct sys_thread *st;
00264 pthread_t pt;
00265
00266 pt = pthread_self();
00267
00268 for(st = threads; st != NULL; st = st->next) {
00269
00270 /* If the thread represented by st has exited and it's memory hasn't been deallocated ... */
00271 if(AND(st->flags,0x81)== 0x80){
00272 sys_free(st->stack);
00273 SET(st->flags, 0x81);
00274 continue;
00275 }
00276
00277 if(pthread_equal(st->pthread, pt))
00278 return st;
00279 }
00280
00281 return NULL;
00282 }
|
Here is the call graph for this function:
|
|
Definition at line 239 of file sys_arch.c. References mallocs, NULL, obtain_index_to_free(), rtl_free, sys_allow_interrupts(), and sys_stop_interrupts(). Referenced by sys_arch_close(), sys_current_thread(), sys_mbox_free(), sys_search_thread(), sys_sem_free(), sys_thread_new(), and thread_start().
00239 {
00240 int index;
00241 unsigned int state;
00242
00243 sys_stop_interrupts(&state);
00244
00245 if(ptr != NULL){
00246 index = obtain_index_to_free(ptr);
00247 if(index != -1){
00248 mallocs[index] = NULL;
00249 rtl_free(ptr);
00250 n_frees++;
00251 }else{
00252 rtl_printf("sys_free: no memory reserved for this pointer\n");
00253 }
00254 }
00255
00256 sys_allow_interrupts(&state);
00257 }
|
Here is the call graph for this function:
|
|
Definition at line 728 of file sys_arch.c. References mallocs, MAX_TIMERS, NULL, sys_timeouts::signal, signal, sys_timeouts::timer_event_spec, and vector_of_timers.
00729 {
00730 int i,retval;
00731
00732 for(i=0; i<=500; i++)
00733 mallocs[i] = NULL;
00734
00735 for(i=0; i<MAX_TIMERS; i++){
00736 vector_of_timers[i].signal = RTL_SIGRTMIN + signal++;
00737 vector_of_timers[i].timer_event_spec.sigev_notify = SIGEV_SIGNAL;
00738 vector_of_timers[i].timer_event_spec.sigev_signo = vector_of_timers[i].signal;
00739 vector_of_timers[i].timer_event_spec.sigev_value.sival_int = 13;
00740
00741 retval = timer_create(CLOCK_REALTIME, &(vector_of_timers[i].timer_event_spec), &(vector_of_timers[i].timer));
00742
00743 if (retval) {
00744 rtl_printf("timer_create(CLOCK_REALTIME) failed:\n");
00745 }
00746 }
00747 }
|
|
|
Definition at line 215 of file sys_arch.c. References malloc_index, mallocs, MAX_VECTOR_MALLOCS, n_mallocs, NULL, rtl_malloc, sys_allow_interrupts(), and sys_stop_interrupts(). Referenced by sys_mbox_new(), sys_sem_new_(), sys_thread_new(), and sys_thread_register().
00215 {
00216 void *tmp;
00217 int entry = malloc_index % MAX_VECTOR_MALLOCS;
00218 unsigned int state;
00219
00220 sys_stop_interrupts(&state);
00221
00222 while(mallocs[entry] != NULL)
00223 entry = ++malloc_index % MAX_VECTOR_MALLOCS;
00224
00225 tmp = mallocs[entry] = rtl_malloc(size);
00226
00227 if(tmp != NULL){
00228 n_mallocs++;
00229 malloc_index++;
00230 }else
00231 rtl_printf("\n\n\n\nERROR: Not enough memory!\n\n\n\n");
00232
00233 sys_allow_interrupts(&state);
00234
00235 return tmp;
00236 }
|
Here is the call graph for this function:
|
||||||||||||
|
Definition at line 764 of file sys_arch.c. References sys_arch_mbox_fetch(), and sys_mbox_t. Referenced by netconn_accept(), netconn_bind(), netconn_close(), netconn_connect(), netconn_delete(), netconn_disconnect(), netconn_listen(), netconn_recv(), netconn_send(), netconn_write(), and tcpip_thread().
00765 {
00766 sys_arch_mbox_fetch(mbox, msg, 0);
00767 }
|
Here is the call graph for this function:
|
|
Definition at line 499 of file sys_arch.c. References sys_mbox::mail, sys_mbox::mutex, NULL, sys_free(), SYS_MBOX_NULL, sys_sem_free(), and sys_sem_wait().
00500 {
00501
00502 if(mbox != SYS_MBOX_NULL) {
00503
00504 sys_sem_wait(mbox->mutex);
00505
00506 sys_sem_free(mbox->mail);
00507 sys_sem_free(mbox->mutex);
00508 mbox->mail = mbox->mutex = NULL;
00509
00510 sys_free(mbox);
00511 }
00512 }
|
Here is the call graph for this function:
|
|
Definition at line 478 of file sys_arch.c. References NULL, sys_malloc(), and sys_sem_new_(). Referenced by do_listen(), netconn_bind(), netconn_connect(), netconn_listen(), netconn_new(), and tcpip_init().
00479 {
00480 struct sys_mbox *mbox;
00481
00482 mbox = sys_malloc(sizeof(struct sys_mbox));
00483
00484 if(mbox != NULL){
00485
00486 mbox->first = mbox->last = 0;
00487 mbox->mail = sys_sem_new_(0);
00488 mbox->mutex = sys_sem_new_(1);
00489
00490 return mbox;
00491 }else{
00492 rtl_printf("ERROR: Not enough memory to create mbox\n");
00493 return NULL;
00494 }
00495 }
|
Here is the call graph for this function:
|
||||||||||||
|
Definition at line 515 of file sys_arch.c. References sys_mbox::first, sys_mbox::last, sys_mbox::mail, sys_mbox::msgs, sys_mbox::mutex, sys_allow_interrupts(), SYS_MBOX_SIZE, sys_sem_signal(), sys_sem_signal_pre(), sys_sem_wait(), sys_stop_interrupts(), and u8_t.
00516 {
00517 u8_t first;
00518 unsigned int state;
00519
00520 sys_sem_wait(mbox->mutex);
00521
00522 mbox->msgs[mbox->last] = msg;
00523
00524 if(mbox->last == mbox->first) {
00525 first = 1;
00526 } else {
00527 first = 0;
00528 }
00529
00530 mbox->last++;
00531 if(mbox->last == SYS_MBOX_SIZE) {
00532 mbox->last = 0;
00533 }
00534
00535 sys_stop_interrupts(&state);
00536
00537 if(first)
00538 sys_sem_signal_pre(mbox->mail);
00539
00540 sys_sem_signal(mbox->mutex);
00541
00542 sys_allow_interrupts(&state);
00543
00544 }
|
Here is the call graph for this function:
|
|
Definition at line 286 of file sys_arch.c. References AND, NULL, SET, sys_free(), and threads. Referenced by sys_thread_delete().
00287 {
00288 struct sys_thread *st;
00289 pthread_t pt = (pthread_t) pthread;
00290
00291 for(st = threads; st != NULL; st = st->next) {
00292
00293 /* If the thread represented by st has exited and it's memory hasn't been deallocated ... */
00294 if(AND(st->flags,0x81)== 0x80){
00295 sys_free(st->stack);
00296 SET(st->flags, 0x81);
00297 continue;
00298 }
00299
00300 if(pthread_equal(st->pthread, pt))
00301 return st;
00302 }
00303
00304 return NULL;
00305 }
|
Here is the call graph for this function:
|
|
Definition at line 694 of file sys_arch.c. References NULL, sys_sem::sem, and sys_free().
|
Here is the call graph for this function:
|
|
Definition at line 588 of file sys_arch.c. References sys_sem_new_(), and u8_t. Referenced by alloc_socket(), event_callback(), lwip_close(), lwip_select(), mem_init(), memp_init(), netconn_write(), and pbuf_init().
00589 {
00590 return sys_sem_new_(count);
00591 }
|
Here is the call graph for this function:
|
|
Definition at line 595 of file sys_arch.c. References NULL, sys_malloc(), and u8_t. Referenced by sys_mbox_new(), and sys_sem_new().
00596 {
00597 struct sys_sem *sem;
00598
00599 sem = sys_malloc(sizeof(struct sys_sem));
00600
00601 if(sem != NULL){
00602 sem->c = count;
00603 sem_init(&(sem->sem),0,count);
00604 return sem;
00605 }else{
00606 rtl_printf("ERROR: Not enough memory to create semaphore\n");
00607 return NULL;
00608 }
00609 }
|
Here is the call graph for this function:
|
|
Definition at line 155 of file sys_arch.c. Referenced by sys_sem_signal().
00156 {
00157 sem_post(sem);
00158 return 0;
00159 }
|
|
|
Definition at line 680 of file sys_arch.c. References sys_sem::c, sys_sem::sem, and sys_sem_post().
|
Here is the call graph for this function:
|
|
Definition at line 162 of file sys_arch.c. References sys_sem::c, and sys_sem::sem. Referenced by sys_mbox_post().
00163 {
00164 rtl_irqstate_t flags;
00165
00166 sem->c++;
00167 if(sem->c > 1){
00168 sem->c = 1;
00169 }
00170 sem->sem.value = sem->c;
00171
00172 // I need this implementation because it doesn't call to rtl_schedule
00173 rtl_spin_lock_irqsave (&sem->sem.lock, flags);
00174
00175 ++(sem->sem.value);
00176 rtl_wait_wakeup (&sem->sem.wait);
00177
00178 rtl_spin_unlock_irqrestore(&sem->sem.lock, flags);
00179
00180 return 0;
00181 }
|
|
|
Definition at line 751 of file sys_arch.c. References sys_arch_sem_wait(), and sys_sem_t. Referenced by alloc_socket(), event_callback(), lwip_accept(), lwip_close(), lwip_select(), mem_free(), mem_malloc(), mem_realloc(), memp_freep(), memp_mallocp(), netconn_close(), netconn_write(), pbuf_refresh(), sys_mbox_free(), and sys_mbox_post().
00752 {
00753 sys_arch_sem_wait(sem, 0);
00754 }
|
Here is the call graph for this function:
|
||||||||||||
|
Definition at line 757 of file sys_arch.c. References sys_arch_sem_wait(), sys_sem_t, and u32_t. Referenced by lwip_select().
00758 {
00759 return sys_arch_sem_wait(sem, timeout);
00760 }
|
Here is the call graph for this function:
|
|
Definition at line 184 of file sys_arch.c. Referenced by pbuf_free(), pbuf_pool_alloc(), pbuf_pool_free(), pbuf_ref(), pbuf_ref_chain(), pbuf_refresh(), sys_free(), sys_malloc(), and sys_mbox_post().
00184 {
00185 rtl_no_interrupts((rtl_irqstate_t) *state);
00186 }
|
|
|
Definition at line 360 of file sys_arch.c. References NULL, SET, and sys_search_thread(). Referenced by cleanup_module().
00361 {
00362 struct sys_thread *thread;
00363
00364 thread = sys_search_thread(pthread);
00365
00366 if(thread != NULL){
00367 if(thread->stack != NULL) //i.e. It is a standalone thread
00368 SET(thread->flags, 0x80);
00369 else SET(thread->flags, 0x81);
00370 pthread_cancel(pthread);
00371 pthread_join(pthread,NULL);
00372 return 0;
00373 }
00374
00375
00376 return -1;
00377 }
|
Here is the call graph for this function:
|
|
Definition at line 344 of file sys_arch.c. References NULL, SET, status, and sys_current_thread(). Referenced by dns_client(), serve_echo(), sock_udpclient(), tcp_client(), and udpclient().
00345 {
00346 struct sys_thread *thread;
00347 void *status = NULL;
00348
00349 thread = sys_current_thread();
00350
00351 if(thread->stack != NULL) //i.e. It is a standalone thread
00352 SET(thread->flags, 0x80);
00353 else SET(thread->flags, 0x81);
00354
00355 pthread_exit(status);
00356 return NULL;
00357 }
|
Here is the call graph for this function:
|
||||||||||||||||
|
Definition at line 406 of file sys_arch.c. References bcopy(), name, NULL, SET, sys_free(), sys_malloc(), thread_start(), and threads. Referenced by init_module(), rt_3com905cif_low_level_init(), rt_rtl8139if_low_level_init(), slipif_init(), tcpecho_thread(), and tcpip_init().
00408 {
00409 struct sys_thread *thread;
00410 struct thread_start_param *thread_param;
00411 pthread_attr_t attr;
00412
00413 thread = sys_malloc(sizeof(struct sys_thread));
00414
00415 if(thread != NULL){
00416
00417 thread->next = threads;
00418
00419 SET(thread->flags, 0x00);
00420
00421 thread->stack = (char *) sys_malloc(sizeof(char)*THREAD_STACK_SIZE);
00422
00423 thread->timeouts = NULL;
00424
00425 #ifdef THREAD_DEBUG
00426 thread->name = (char *) sys_malloc(20);
00427 bcopy(name, thread->name, name_len);
00428 #endif
00429
00430 if(thread->stack == NULL){
00431 sys_free(thread);
00432 rtl_printf("ERROR: Not enough memory to create new thread's stack\n");
00433 return NULL;
00434 }
00435
00436 threads = thread;
00437
00438 pthread_attr_init(&attr);
00439
00440
00441 /* Because it's a thread which is trying to create another thread, RTLinux
00442 only allows that by passing to the new thread it's stack */
00443 pthread_attr_setstackaddr(&attr, thread->stack);
00444 pthread_attr_setstacksize(&attr, THREAD_STACK_SIZE);
00445 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
00446
00447 thread_param = sys_malloc(sizeof(struct thread_start_param));
00448
00449 if(thread_param == NULL){
00450 sys_free(thread->stack);
00451 sys_free(thread);
00452 rtl_printf("ERROR: Not enough memory to create thread start param\n");
00453 return NULL;
00454 }
00455
00456 thread_param->function = function;
00457 thread_param->arg = arg;
00458 thread_param->thread = thread;
00459
00460 if(pthread_create(&(thread->pthread),&attr, thread_start, thread_param)) {
00461 rtl_printf("\nsys_thread_new: pthread_create 0x%x 0x%x\n", pthread_self(),thread->pthread);
00462 rtl_printf("Kernel Panic\n");
00463 return NULL;
00464 }
00465
00466 if(period != 0)
00467 pthread_make_periodic_np(thread->pthread, gethrtime(), period);
00468
00469 return (void *) thread->pthread;
00470 }
00471
00472 rtl_printf("ERROR: Not enough memory to create thread\n");
00473 return NULL;
00474 }
|
Here is the call graph for this function:
|
|
Definition at line 380 of file sys_arch.c. References NULL, sys_thread::pthread, SET, sys_malloc(), and threads. Referenced by tcp_client().
00381 {
00382 struct sys_thread *thread;
00383
00384 thread = sys_malloc(sizeof(struct sys_thread));
00385
00386
00387 thread->next = threads;
00388 thread->pthread = (pthread_t) pthread;
00389 thread->stack = NULL;
00390 thread->timeouts = NULL;
00391
00392 SET(thread->flags, 0x01);
00393 threads = thread;
00394
00395 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
00396 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
00397
00398 }
|
Here is the call graph for this function:
|
||||||||||||||||
|
Definition at line 770 of file sys_arch.c. References NULL, sys_current_thread(), sys_timeout_handler, timer_index, u16_t, and vector_of_timers. Referenced by ip_reass(), ip_reass_timer(), rt_3c905cif_init(), rt_3com905cif_etharp_timer(), rt_rtl8139_ifetharp_timer(), rt_rtl8139if_init(), and tcpip_thread().
00771 {
00772 struct sys_thread *thread;
00773 int err, sec = 0, nsec = 0;
00774
00775 thread = sys_current_thread();
00776
00777 if(thread->timeouts == NULL){
00778 thread->timeouts = &vector_of_timers[timer_index++];
00779 }
00780
00781 thread->timeouts->sa.sa_handler = h;
00782 thread->timeouts->sa.sa_mask=0;
00783 thread->timeouts->sa.sa_flags=0;
00784 thread->timeouts->sa.sa_focus=0;
00785
00786 rtl_sigemptyset(&(thread->timeouts->sa.sa_mask));
00787
00788 if (sigaction(thread->timeouts->signal, &(thread->timeouts->sa), NULL)) {
00789 rtl_printf("sigaction failed");
00790 }
00791
00792 if(msecs >= 100){
00793 sec = msecs / 1000;
00794 nsec = (msecs % 1000) * 1000000 ;
00795 }else{
00796 nsec = msecs * 1000000;
00797 }
00798
00799 thread->timeouts->ospec.it_value.tv_sec = sec;
00800 thread->timeouts->ospec.it_value.tv_nsec = nsec;
00801 thread->timeouts->ospec.it_interval.tv_sec = 0;
00802 thread->timeouts->ospec.it_interval.tv_nsec = 0;
00803
00804 err = timer_settime(thread->timeouts->timer, 0, &(thread->timeouts->ospec), &(thread->timeouts->old_setting));
00805
00806 return;
00807 }
|
Here is the call graph for this function:
|
||||||||||||
|
Definition at line 810 of file sys_arch.c. References NULL, sys_current_thread(), and sys_timeout_handler. Referenced by ip_reass().
00810 {
00811 struct sys_thread *thread;
00812
00813 thread = sys_current_thread();
00814
00815 if(thread->timeouts != NULL)
00816 timer_delete(thread->timeouts->timer);
00817 }
|
Here is the call graph for this function:
|
|
Definition at line 328 of file sys_arch.c. References NULL, and sys_free(). Referenced by sys_thread_new().
00329 {
00330 struct thread_start_param *tp = arg;
00331
00332 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
00333 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
00334
00335 tp->thread->pthread = pthread_self();
00336 tp->function(tp->arg);
00337
00338 sys_free(tp);
00339
00340 return NULL;
00341 }
|
Here is the call graph for this function:
|
||||||||||||
|
Definition at line 612 of file sys_arch.c. References gettimeofday(), sys_sem::sem, timeval::tv_sec, timeval::tv_usec, and u16_t. Referenced by sys_arch_sem_wait().
00612 {
00613 unsigned int tdiff;
00614 unsigned long sec, usec;
00615 struct timeval rtime1, rtime2;
00616 struct timespec ts;
00617 struct timezone tz;
00618 int retval;
00619
00620 if(timeout > 0) {
00621 /* Get a timestamp and add the timeout value. */
00622 gettimeofday(&rtime1, &tz);
00623
00624 sec = rtime1.tv_sec;
00625 usec = rtime1.tv_usec;
00626 usec += timeout % 1000 * 1000;
00627 sec += (int)(timeout / 1000) + (int)(usec / 1000000);
00628 usec = usec % 1000000;
00629 ts.tv_nsec = usec * 1000;
00630 ts.tv_sec = sec;
00631
00632 retval = sem_timedwait(&(sem->sem),&ts);
00633
00634 if(retval == -1) {
00635 return 0;
00636 } else {
00637 /* Calculate for how long we waited for the cond. */
00638 gettimeofday(&rtime2, &tz);
00639 tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 +
00640 (rtime2.tv_usec - rtime1.tv_usec) / 1000;
00641 if(tdiff == 0) {
00642 return 1;
00643 }
00644 return tdiff;
00645 }
00646 } else {
00647 sem_wait(&(sem->sem));
00648 return 0;
00649 }
00650 }
|
Here is the call graph for this function:
|
|
Definition at line 106 of file sys_arch.c. Referenced by sys_malloc(). |
|
|
Definition at line 105 of file sys_arch.c. Referenced by free_all_resources(), obtain_index_to_free(), sys_free(), sys_init(), and sys_malloc(). |
|
|
Definition at line 107 of file sys_arch.c. Referenced by sys_malloc(). |
|
|
Definition at line 120 of file sys_arch.c. Referenced by sys_init(). |
|
|
Definition at line 101 of file sys_arch.c. Referenced by sys_arch_close(), sys_current_thread(), sys_search_thread(), sys_thread_new(), and sys_thread_register(). |
|
|
Definition at line 119 of file sys_arch.c. Referenced by sys_timeout(). |
|
|
Definition at line 118 of file sys_arch.c. Referenced by sys_init(), and sys_timeout(). |
1.3.4