source: rtems/cpukit/rtems/src/clocktick.c @ d19cce29

4.115
Last change on this file since d19cce29 was d19cce29, checked in by Sebastian Huber <sebastian.huber@…>, on 08/05/13 at 12:54:11

score: Per-CPU thread dispatch disable level

Use a per-CPU thread dispatch disable level. So instead of one global
thread dispatch disable level we have now one instance per processor.
This is a major performance improvement for SMP. On non-SMP
configurations this may simplifiy the interrupt entry/exit code.

The giant lock is still present, but it is now decoupled from the thread
dispatching in _Thread_Dispatch(), _Thread_Handler(),
_Thread_Restart_self() and the interrupt entry/exit. Access to the
giant lock is now available via _Giant_Acquire() and _Giant_Release().
The giant lock is still implicitly acquired via
_Thread_Dispatch_decrement_disable_level().

The giant lock is only acquired for high-level operations in interrupt
handlers (e.g. release of a semaphore, sending of an event).

As a side-effect this change fixes the lost thread dispatch necessary
indication bug in _Thread_Dispatch().

A per-CPU thread dispatch disable level greatly simplifies the SMP
support for the interrupt entry/exit code since no spin locks have to be
acquired in this area. It is only necessary to get the current
processor index and use this to calculate the address of the own per-CPU
control. This reduces the interrupt latency considerably.

All elements for the interrupt entry/exit code are now part of the
Per_CPU_Control structure: thread dispatch disable level, ISR nest level
and thread dispatch necessary. Nothing else is required (except CPU
port specific stuff like on SPARC).

  • Property mode set to 100644
File size: 948 bytes
Line 
1/**
2 *  @file
3 *
4 *  @brief Announce a Clock Tick
5 *  @ingroup ClassicClock
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2009.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/clock.h>
22#include <rtems/score/schedulerimpl.h>
23#include <rtems/score/threadimpl.h>
24#include <rtems/score/todimpl.h>
25#include <rtems/score/watchdogimpl.h>
26
27rtems_status_code rtems_clock_tick( void )
28{
29#if defined( RTEMS_SMP )
30  _Thread_Disable_dispatch();
31#endif
32
33  _TOD_Tickle_ticks();
34
35  _Watchdog_Tickle_ticks();
36
37  _Scheduler_Tick();
38
39#if defined( RTEMS_SMP )
40  _Thread_Enable_dispatch();
41#else
42  if ( _Thread_Is_context_switch_necessary() &&
43       _Thread_Dispatch_is_enabled() )
44    _Thread_Dispatch();
45#endif
46
47  return RTEMS_SUCCESSFUL;
48}
Note: See TracBrowser for help on using the repository browser.