GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_utility_semaphore_get.c Lines: 7 7 100.0 %
Date: 2026-03-06 18:57:10 Branches: 2 2 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** USBX Component                                                        */
17
/**                                                                       */
18
/**   Utility                                                             */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
24
/* Include necessary system files.  */
25
26
#define UX_SOURCE_CODE
27
28
#include "ux_api.h"
29
30
31
#if !defined(UX_STANDALONE)
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _ux_utility_semaphore_get                           PORTABLE C      */
37
/*                                                           6.1.11       */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Chaoqiong Xiao, Microsoft Corporation                               */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function gets a semaphore signal.                              */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    semaphore                             Semaphore to get signal from  */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    Completion Status                                                   */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    tx_thread_identify                    ThreadX identify thread       */
57
/*    tx_thread_info_get                    ThreadX get thread info       */
58
/*    tx_semaphore_get                      ThreadX semaphore get         */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    USBX Components                                                     */
63
/*                                                                        */
64
/**************************************************************************/
65
219589
UINT  _ux_utility_semaphore_get(UX_SEMAPHORE *semaphore, ULONG semaphore_signal)
66
{
67
68
UINT        status;
69
UX_THREAD   *my_thread;
70
CHAR        *name;
71
UINT        state;
72
ULONG       run_count;
73
UINT        priority;
74
UINT        preemption_threshold;
75
ULONG       time_slice;
76
UX_THREAD   *next_thread;
77
UX_THREAD   *suspended_thread;
78
79
    /* Call TX to know my own tread.  */
80
219589
    my_thread = tx_thread_identify();
81
82
    /* Retrieve information about the previously created thread "my_thread." */
83
219589
    tx_thread_info_get(my_thread, &name, &state, &run_count,
84
                       &priority, &preemption_threshold,
85
                       &time_slice, &next_thread,&suspended_thread);
86
87
    /* Is this the lowest priority thread in the system trying to use TX services ? */
88
219589
    if (priority > _ux_system -> ux_system_thread_lowest_priority)
89
    {
90
91
        /* We need to remember this thread priority.  */
92
667
        _ux_system -> ux_system_thread_lowest_priority = priority;
93
94
    }
95
96
    /* Get ThreadX semaphore instance.  */
97
219589
    status =  tx_semaphore_get(semaphore, semaphore_signal);
98
99
    /* Return completion status.  */
100
218601
    return(status);
101
}
102
#endif