Linux Face / QPFramework
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers qf_act.cpp Source File

qf_act.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 // Product: QF/C++
00003 // Last Updated for Version: 4.1.03
00004 // Date of the Last Update:  Feb 15, 2010
00005 //
00006 //                    Q u a n t u m     L e a P s
00007 //                    ---------------------------
00008 //                    innovating embedded systems
00009 //
00010 // Copyright (C) 2002-2010 Quantum Leaps, LLC. All rights reserved.
00011 //
00012 // This software may be distributed and modified under the terms of the GNU
00013 // General Public License version 2 (GPL) as published by the Free Software
00014 // Foundation and appearing in the file GPL.TXT included in the packaging of
00015 // this file. Please note that GPL Section 2[b] requires that all works based
00016 // on this software must also be made publicly available under the terms of
00017 // the GPL ("Copyleft").
00018 //
00019 // Alternatively, this software may be distributed and modified under the
00020 // terms of Quantum Leaps commercial licenses, which expressly supersede
00021 // the GPL and are specifically designed for licensees interested in
00022 // retaining the proprietary status of their code.
00023 //
00024 // Contact information:
00025 // Quantum Leaps Web site:  http://www.quantum-leaps.com
00026 // e-mail:                  info@quantum-leaps.com
00027 //////////////////////////////////////////////////////////////////////////////
00028 #include "qf_pkg.h"
00029 #include "qassert.h"
00030 
00031 Q_DEFINE_THIS_MODULE(qf_act)
00032 
00033 /// \file
00034 /// \ingroup qf
00035 /// \brief QF::active_[], QF::getVersion(), and QF::add_()/QF::remove_()
00036 /// implementation.
00037 
00038 // public objects ------------------------------------------------------------
00039 QActive *QF::active_[QF_MAX_ACTIVE + 1];        // to be used by QF ports only
00040 uint8_t QF_intLockNest_;                       // interrupt-lock nesting level
00041 
00042 //............................................................................
00043 //lint -e970 -e971               ignore MISRA rules 13 and 14 in this function
00044 const char Q_ROM * Q_ROM_VAR QF::getVersion(void) {
00045     static char const Q_ROM Q_ROM_VAR version[] = {
00046         ((QP_VERSION >> 12) & 0xF) + '0',
00047         '.',
00048         ((QP_VERSION >>  8) & 0xF) + '0',
00049         '.',
00050         ((QP_VERSION >>  4) & 0xF) + '0',
00051         (QP_VERSION         & 0xF) + '0',
00052         '\0'
00053     };
00054     return version;
00055 }
00056 //............................................................................
00057 void QF::add_(QActive *a) {
00058     uint8_t p = a->m_prio;
00059 
00060     Q_REQUIRE(((uint8_t)0 < p) && (p <= (uint8_t)QF_MAX_ACTIVE)
00061               && (active_[p] == (QActive *)0));
00062 
00063     QF_INT_LOCK_KEY_
00064     QF_INT_LOCK_();
00065 
00066     active_[p] = a;            // registger the active object at this priority
00067 
00068     QS_BEGIN_NOLOCK_(QS_QF_ACTIVE_ADD, QS::aoObj_, a)
00069         QS_TIME_();                                               // timestamp
00070         QS_OBJ_(a);                                       // the active object
00071         QS_U8_(p);                        // the priority of the active object
00072     QS_END_NOLOCK_()
00073 
00074     QF_INT_UNLOCK_();
00075 }
00076 //............................................................................
00077 void QF::remove_(QActive const *a) {
00078     uint8_t p = a->m_prio;
00079 
00080     Q_REQUIRE(((uint8_t)0 < p) && (p <= (uint8_t)QF_MAX_ACTIVE)
00081               && (active_[p] == a));
00082 
00083     QF_INT_LOCK_KEY_
00084     QF_INT_LOCK_();
00085 
00086     active_[p] = (QActive *)0;                   // free-up the priority level
00087 
00088     QS_BEGIN_(QS_QF_ACTIVE_REMOVE, QS::aoObj_, a)
00089         QS_TIME_();                                               // timestamp
00090         QS_OBJ_(a);                                       // the active object
00091         QS_U8_(p);                        // the priority of the active object
00092     QS_END_NOLOCK_()
00093 
00094     QF_INT_UNLOCK_();
00095 }