Changeset aa05cfbb in rtems


Ignore:
Timestamp:
May 11, 2015, 12:56:49 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
d5423295
Parents:
d8752860
git-author:
Sebastian Huber <sebastian.huber@…> (05/11/15 12:56:49)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/19/15 10:00:48)
Message:

score: Replace _Thread_Delay_ended()

Use _Thread_Timeout() instead. Use pseudo thread queue for nanosleep()
to deal with signals.

Close #2130.

Location:
cpukit
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/nanosleep.c

    rd8752860 raa05cfbb  
    2424#include <rtems/seterr.h>
    2525#include <rtems/score/threadimpl.h>
     26#include <rtems/score/threadqimpl.h>
    2627#include <rtems/score/timespec.h>
    2728#include <rtems/score/watchdogimpl.h>
     29
     30static Thread_queue_Control _Nanosleep_Pseudo_queue =
     31  THREAD_QUEUE_FIFO_INITIALIZER( _Nanosleep_Pseudo_queue, "Nanosleep" );
    2832
    2933/*
     
    3943   * disabled on SMP configurations.
    4044   */
    41   Thread_Control *executing;
     45  Thread_Control  *executing;
     46  Per_CPU_Control *cpu_self;
    4247
    4348  Watchdog_Interval  ticks;
     
    5964  ticks = _Timespec_To_ticks( rqtp );
    6065
     66  executing = _Thread_Get_executing();
     67
    6168  /*
    6269   *  A nanosleep for zero time is implemented as a yield.
     
    6572   */
    6673  if ( !ticks ) {
    67     _Thread_Disable_dispatch();
    68       executing = _Thread_Executing;
     74    cpu_self = _Thread_Dispatch_disable();
    6975      _Thread_Yield( executing );
    70     _Thread_Enable_dispatch();
     76    _Thread_Dispatch_enable( cpu_self );
    7177    if ( rmtp ) {
    7278       rmtp->tv_sec = 0;
     
    7985   *  Block for the desired amount of time
    8086   */
    81   _Thread_Disable_dispatch();
    82     executing = _Thread_Executing;
    83     _Thread_Set_state(
    84       executing,
    85       STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL
    86     );
    87     _Watchdog_Initialize(
    88       &executing->Timer,
    89       _Thread_Delay_ended,
    90       0,
    91       executing
    92     );
    93     _Watchdog_Insert_ticks( &executing->Timer, ticks );
    94   _Thread_Enable_dispatch();
     87  _Thread_queue_Enqueue(
     88    &_Nanosleep_Pseudo_queue,
     89    executing,
     90    STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL,
     91    ticks,
     92    0
     93  );
    9594
    9695  /*
  • cpukit/posix/src/psignalunblockthread.c

    rd8752860 raa05cfbb  
    111111    if ( _States_Is_interruptible_by_signal( the_thread->current_state ) ) {
    112112      the_thread->Wait.return_code = EINTR;
    113       /*
    114        *  In pthread_cond_wait, a thread will be blocking on a thread
    115        *  queue, but is also interruptible by a POSIX signal.
    116        */
    117        if ( _States_Is_delaying(the_thread->current_state) ) {
    118           _Watchdog_Remove_ticks( &the_thread->Timer );
    119           _Thread_Unblock( the_thread );
    120        } else {
    121          _Thread_queue_Extract_with_proxy( the_thread );
    122        }
     113      _Thread_queue_Extract_with_proxy( the_thread );
    123114    }
    124115  }
  • cpukit/rtems/src/taskwakeafter.c

    rd8752860 raa05cfbb  
    3131   * disabled on SMP configurations.
    3232   */
    33   Thread_Control *executing;
     33  Thread_Control  *executing;
     34  Per_CPU_Control *cpu_self;
    3435
    35   _Thread_Disable_dispatch();
     36  cpu_self = _Thread_Dispatch_disable();
    3637    executing = _Thread_Executing;
    3738
     
    4041    } else {
    4142      _Thread_Set_state( executing, STATES_DELAYING );
     43      _Thread_Wait_flags_set( executing, THREAD_WAIT_STATE_BLOCKED );
    4244      _Watchdog_Initialize(
    4345        &executing->Timer,
    44         _Thread_Delay_ended,
     46        _Thread_Timeout,
    4547        0,
    4648        executing
     
    4850      _Watchdog_Insert_ticks( &executing->Timer, ticks );
    4951    }
    50   _Thread_Enable_dispatch();
     52  _Thread_Dispatch_enable( cpu_self );
    5153  return RTEMS_SUCCESSFUL;
    5254}
  • cpukit/rtems/src/taskwakewhen.c

    rd8752860 raa05cfbb  
    3131  Watchdog_Interval   seconds;
    3232  Thread_Control     *executing;
     33  Per_CPU_Control    *cpu_self;
    3334
    3435  if ( !_TOD_Is_set() )
     
    4849    return RTEMS_INVALID_CLOCK;
    4950
    50   _Thread_Disable_dispatch();
     51  cpu_self = _Thread_Dispatch_disable();
    5152    executing = _Thread_Executing;
    5253    _Thread_Set_state( executing, STATES_WAITING_FOR_TIME );
     54    _Thread_Wait_flags_set( executing, THREAD_WAIT_STATE_BLOCKED );
    5355    _Watchdog_Initialize(
    5456      &executing->Timer,
    55       _Thread_Delay_ended,
     57      _Thread_Timeout,
    5658      0,
    5759      executing
     
    6163      seconds - _TOD_Seconds_since_epoch()
    6264    );
    63   _Thread_Enable_dispatch();
     65  _Thread_Dispatch_enable( cpu_self );
    6466  return RTEMS_SUCCESSFUL;
    6567}
  • cpukit/score/Makefile.am

    rd8752860 raa05cfbb  
    281281libscore_a_SOURCES += src/thread.c src/threadchangepriority.c \
    282282    src/threadclearstate.c src/threadcreateidle.c \
    283     src/threaddelayended.c src/threaddispatch.c \
     283    src/threaddispatch.c \
    284284    src/threadenabledispatch.c src/threaddisabledispatch.c \
    285285    src/threadget.c src/threadhandler.c src/threadinitialize.c \
Note: See TracChangeset for help on using the changeset viewer.