GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_system_unlock.c Lines: 9 9 100.0 %
Date: 2026-03-06 19:21:09 Branches: 6 6 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
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   System Management (System)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_system_unlock                                   PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function unlocks the GUIX system mutex                         */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    None                                                                */
48
/*                                                                        */
49
/*  OUTPUT                                                                */
50
/*                                                                        */
51
/*    None                                                                */
52
/*                                                                        */
53
/*  CALLS                                                                 */
54
/*                                                                        */
55
/*    tx_mutex_put                          Release the mutex             */
56
/*     _gx_system_error_process             Process system error          */
57
/*                                                                        */
58
/*  CALLED BY                                                             */
59
/*                                                                        */
60
/*    GUIX Internal Code                                                  */
61
/*                                                                        */
62
/**************************************************************************/
63
689257
VOID  _gx_system_unlock(VOID)
64
{
65
#ifdef GX_THREADX_BINDING
66
UINT protection_status;
67
#endif
68
69
689257
    if (_gx_system_lock_nesting > 0)
70
    {
71
689241
        _gx_system_lock_nesting--;
72
73
689241
        if (_gx_system_lock_nesting == 0)
74
        {
75
            /* no thread has GUIX locked */
76
564098
            _gx_system_lock_thread = GX_NULL;
77
78
            /* Release the protection prior to blocking on the event queue.  */
79
80
#ifdef GX_THREADX_BINDING
81
564098
            protection_status =  tx_mutex_put(&_gx_system_protect);
82
            /* Determine if the protection was successfully released.  */
83
564098
            if (protection_status)
84
            {
85
86
                /* Error releasing protection - call system error handler.  */
87
96877
                _gx_system_error_process(GX_SYSTEM_PROTECTION_ERROR);
88
89
                /* Return to exit the system thread.  */
90
96877
                return;
91
            }
92
#else
93
            GX_SYSTEM_MUTEX_UNLOCK;
94
#endif
95
        }
96
    }
97
}
98