source: rtems/cpukit/posix/src/timerdelete.c @ dbb30e26

5
Last change on this file since dbb30e26 was bf2a53d2, checked in by Sebastian Huber <sebastian.huber@…>, on 10/14/17 at 13:14:53

score: Rename watchdog variants

Rename PER_CPU_WATCHDOG_RELATIVE in PER_CPU_WATCHDOG_MONOTONIC to
highlight the corresponding POSIX CLOCK_MONOTONIC.

Rename PER_CPU_WATCHDOG_ABSOLUTE in PER_CPU_WATCHDOG_REALTIME to
highlight the corresponding POSIX CLOCK_REALTIME.

Update #3117.
Update #3182.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief Deletes a POSIX Interval Timer
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  14.2.3 Delete a Per_process Timer, P1003.1b-1993, p. 266
10 *
11 *  COPYRIGHT (c) 1989-2007.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#if HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <time.h>
24#include <errno.h>
25#include <pthread.h>
26
27#include <rtems/system.h>
28#include <rtems/seterr.h>
29#include <rtems/score/thread.h>
30#include <rtems/score/watchdogimpl.h>
31#include <rtems/posix/timerimpl.h>
32
33
34int timer_delete(
35  timer_t timerid
36)
37{
38 /*
39  * IDEA: This function must probably stop the timer first and then delete it
40  *
41  *       It will have to do a call to rtems_timer_cancel and then another
42  *       call to rtems_timer_delete.
43  *       The call to rtems_timer_delete will be probably unnecessary,
44  *       because rtems_timer_delete stops the timer before deleting it.
45  */
46  POSIX_Timer_Control *ptimer;
47  ISR_lock_Context     lock_context;
48
49  _Objects_Allocator_lock();
50
51  ptimer = _POSIX_Timer_Get( timerid, &lock_context );
52  if ( ptimer != NULL ) {
53    Per_CPU_Control *cpu;
54
55    _Objects_Close( &_POSIX_Timer_Information, &ptimer->Object );
56    cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
57    ptimer->state = POSIX_TIMER_STATE_FREE;
58    _Watchdog_Remove(
59      &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ],
60      &ptimer->Timer
61    );
62    _POSIX_Timer_Release( cpu, &lock_context );
63    _POSIX_Timer_Free( ptimer );
64    _Objects_Allocator_unlock();
65    return 0;
66  }
67
68  _Objects_Allocator_unlock();
69
70  rtems_set_errno_and_return_minus_one( EINVAL );
71}
Note: See TracBrowser for help on using the repository browser.