Ignore:
Timestamp:
Jan 13, 2021, 12:36:17 AM (3 years ago)
Author:
alain
Message:

All modifications required to support the <tcp_chat> application
including error recovery in case of packet loss.A

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_thread_wakeup.c

    r637 r683  
    11/*
    2  * sys_thread_wakeup.c - wakeup indicated thread
     2 * sys_thread_wakeup.c - unblock indicated thread from the SLEEP condition
    33 *
    4  * Author    Alain Greiner (2016,2017,2018,2019)
     4 * Author    Alain Greiner     (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2727#include <process.h>
    2828#include <errno.h>
    29 
    3029#include <syscalls.h>
    3130
     
    3635    process_t * process = this->process;
    3736
    38 #if (DEBUG_SYS_THREAD_WAKEUP || CONFIG_INSTRUMENTATION_SYSCALLS)
    39 uint64_t     tm_start = hal_get_cycles();
     37#if DEBUG_SYS_THREAD_WAKEUP || DEBUG_SYSCALLS_ERROR || CONFIG_INTRUMENTATION_SYSCALLS
     38cycle_t      tm_start = hal_get_cycles();
    4039#endif
    4140
    4241#if DEBUG_SYS_THREAD_WAKEUP
    43 if( DEBUG_SYS_THREAD_WAKEUP < tm_start )
    44 printk("\n[%s] thread %x in process enter to activate thread %x / cycle %d\n",
    45 __FUNCTION__, this->trdid, process->pid, trdid, (uint32_t)tm_start );
     42if( DEBUG_SYS_THREAD_WAKEUP < (uint32_t)tm_start )
     43printk("\n[%s] thread[%x,%x] enter to activate thread %x / cycle %d\n",
     44__FUNCTION__, process->pid, this->trdid, trdid, (uint32_t)tm_start );
    4645#endif
    4746
     
    5655
    5756#if DEBUG_SYSCALLS_ERROR
    58 printk("\n[ERROR] in %s : thread %x in process %x / illegal trdid argument %x\n",
    59 __FUNCTION__, this->trdid, process->pid, trdid );
     57if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
     58printk("\n[ERROR] in %s : thread[%x,%x] / illegal trdid argument %x\n",
     59__FUNCTION__, process->pid, this->trdid, trdid );
    6060#endif
    6161                this->errno = EINVAL;
     
    7070
    7171#if DEBUG_SYSCALLS_ERROR
    72 printk("\n[ERROR] in %s : thread %x in process %x cannot find thread %x/n",
    73 __FUNCTION__ , this->trdid, process->pid, trdid );
     72if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
     73printk("\n[ERROR] in %s : thread[%x,%x] / cannot find thread[%x,%x]\n",
     74__FUNCTION__, process->pid, this->trdid, process->pid, trdid );
    7475#endif
    7576        CURRENT_THREAD->errno = EINVAL;
     
    7778    }
    7879
     80    // get target thread cluster and local pointer
     81    thread_t * tgt_ptr = GET_PTR( thread_xp );
     82    cxy_t      tgt_cxy = GET_CXY( thread_xp );
     83
     84    // get state of the target thread alarm
     85    bool_t linked = hal_remote_l32( XPTR( tgt_cxy , &tgt_ptr->alarm.linked ) );
     86
     87    // delete the alarm if active
     88    if( linked ) alarm_stop( thread_xp );
     89
    7990    // unblock target thread
    80     thread_unblock( thread_xp , THREAD_BLOCKED_GLOBAL );
     91    thread_unblock( thread_xp , THREAD_BLOCKED_SLEEP );
    8192
    8293#if (DEBUG_SYS_THREAD_WAKEUP || CONFIG_INSTRUMENTATION_SYSCALLS)
     
    8798#if DEBUG_SYS_THREAD_WAKEUP
    8899if( DEBUG_SYS_THREAD_WAKEUP < tm_end )
    89 printk("\n[%s] thread %x in process %x exit / thread %x activated / cycle %d\n",
    90 __FUNCTION__ , this->trdid, process->pid, trdid, (uint32_t)tm_end );
     100printk("\n[%s] thread[%x,%x] exit / thread[%x,%x] activated / cycle %d\n",
     101__FUNCTION__ , process->pid, this->trdid, process->pid, trdid, (uint32_t)tm_end );
    91102#endif
    92103
Note: See TracChangeset for help on using the changeset viewer.