source: rtems/cpukit/rtems/src/tasksuspend.c @ 2d2352b

4.115
Last change on this file since 2d2352b was 2d2352b, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/13 at 09:48:57

score: Add and use _Objects_Put()

Add and use _Objects_Put_without_thread_dispatch(). These two functions
pair with the _Objects_Get() function. This helps to introduce object
specific SMP locks to avoid lock contention.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Suspend Task
5 *  @ingroup ClassicTasks
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
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/system.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/rtems/modes.h>
25#include <rtems/score/object.h>
26#include <rtems/score/stack.h>
27#include <rtems/score/states.h>
28#include <rtems/rtems/tasks.h>
29#include <rtems/score/thread.h>
30#include <rtems/score/threadq.h>
31#include <rtems/score/tod.h>
32#include <rtems/score/wkspace.h>
33#include <rtems/score/apiext.h>
34#include <rtems/score/sysstate.h>
35
36rtems_status_code rtems_task_suspend(
37  rtems_id id
38)
39{
40  register Thread_Control *the_thread;
41  Objects_Locations        location;
42
43  the_thread = _Thread_Get( id, &location );
44  switch ( location ) {
45
46    case OBJECTS_LOCAL:
47      if ( !_States_Is_suspended( the_thread->current_state ) ) {
48        _Thread_Suspend( the_thread );
49        _Objects_Put( &the_thread->Object );
50        return RTEMS_SUCCESSFUL;
51      }
52      _Objects_Put( &the_thread->Object );
53      return RTEMS_ALREADY_SUSPENDED;
54
55#if defined(RTEMS_MULTIPROCESSING)
56    case OBJECTS_REMOTE:
57      return _RTEMS_tasks_MP_Send_request_packet(
58        RTEMS_TASKS_MP_SUSPEND_REQUEST,
59        id,
60        0,          /* Not used */
61        0,          /* Not used */
62        0           /* Not used */
63      );
64#endif
65
66    case OBJECTS_ERROR:
67      break;
68  }
69
70  return RTEMS_INVALID_ID;
71}
Note: See TracBrowser for help on using the repository browser.