source: rtems/cpukit/rtems/src/tasksuspend.c @ eb02f47

4.104.114.84.95
Last change on this file since eb02f47 was eb02f47, checked in by Joel Sherrill <joel.sherrill@…>, on 11/10/99 at 13:48:27

Committed modifications from ITRON Task and Task Dependendent Synchronization
Working Group. Included are tests.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  RTEMS Task Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/rtems/status.h>
18#include <rtems/rtems/support.h>
19#include <rtems/rtems/modes.h>
20#include <rtems/score/object.h>
21#include <rtems/score/stack.h>
22#include <rtems/score/states.h>
23#include <rtems/rtems/tasks.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/threadq.h>
26#include <rtems/score/tod.h>
27#include <rtems/score/userext.h>
28#include <rtems/score/wkspace.h>
29#include <rtems/score/apiext.h>
30#include <rtems/score/sysstate.h>
31
32/*PAGE
33 *
34 *  rtems_task_suspend
35 *
36 *  This directive will place the specified thread in the "suspended"
37 *  state.  Note that the suspended state can be in addition to
38 *  other waiting states.
39 *
40 *  Input parameters:
41 *    id - thread id
42 *
43 *  Output parameters:
44 *    RTEMS_SUCCESSFUL - if successful
45 *    error code        - if unsuccessful
46 */
47
48rtems_status_code rtems_task_suspend(
49  Objects_Id id
50)
51{
52  register Thread_Control *the_thread;
53  Objects_Locations               location;
54
55  the_thread = _Thread_Get( id, &location );
56  switch ( location ) {
57
58    case OBJECTS_REMOTE:
59#if defined(RTEMS_MULTIPROCESSING)
60      return _RTEMS_tasks_MP_Send_request_packet(
61        RTEMS_TASKS_MP_SUSPEND_REQUEST,
62        id,
63        0,          /* Not used */
64        0,          /* Not used */
65        0           /* Not used */
66      );
67#endif
68
69    case OBJECTS_ERROR:
70      return RTEMS_INVALID_ID;
71
72    case OBJECTS_LOCAL:
73      if ( !_States_Is_suspended( the_thread->current_state ) ) {
74        _Thread_Suspend( the_thread );
75        _Thread_Enable_dispatch();
76        return RTEMS_SUCCESSFUL;
77      }
78      _Thread_Enable_dispatch();
79      return RTEMS_ALREADY_SUSPENDED;
80  }
81
82  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
83}
Note: See TracBrowser for help on using the repository browser.