⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pmc.c

📁 test file nucleus source
💻 C
📖 第 1 页 / 共 3 页
字号:
/* CALLED BY                                                             *//*                                                                       *//*      Application                                                      *//*      PMCE_Delete_Partition_Pool          Error checking shell         *//*                                                                       *//* CALLS                                                                 *//*                                                                       *//*      CSC_Remove_From_List                Remove node from list        *//*      [HIC_Make_History_Entry]            Make entry in history log    *//*      TCC_Resume_Task                     Resume a suspended task      *//*      [TCT_Check_Stack]                   Stack checking function      *//*      TCT_Control_To_System               Transfer control to system   *//*      TCT_Protect                         Protect created list         *//*      TCT_Set_Current_Protect             Modify current protection    *//*      TCT_System_Protect                  Setup system protection      *//*      TCT_System_Unprotect                Release system protection    *//*      TCT_Unprotect                       Release protection           *//*                                                                       *//* INPUTS                                                                *//*                                                                       *//*      pool_ptr                            Partition pool control block *//*                                            pointer                    *//*                                                                       *//* OUTPUTS                                                               *//*                                                                       *//*      NU_SUCCESS                                                       *//*                                                                       *//* HISTORY                                                               *//*                                                                       *//*         DATE                    REMARKS                               *//*                                                                       *//*      03-01-1993      Created initial version 1.0                      *//*      04-19-1993      Verified version 1.0                             *//*      03-01-1994      Changed function interfaces to                   *//*                      match those in prototype,                        *//*                      added register options, changed                  *//*                      protection logic to reduce                       *//*                      overhead, resulting in                           *//*                      version 1.1                                      *//*                                                                       *//*      03-18-1994      Verified version 1.1                             *//*                                                                       *//*************************************************************************/STATUS  PMC_Delete_Partition_Pool(NU_PARTITION_POOL *pool_ptr){R1 PM_PCB      *pool;                       /* Pool control block ptr    */PM_SUSPEND     *suspend_ptr;                /* Suspend block pointer     */PM_SUSPEND     *next_ptr;                   /* Next suspend block        */STATUS          preempt;                    /* Status for resume call    */NU_SUPERV_USER_VARIABLES    /* Switch to supervisor mode */    NU_SUPERVISOR_MODE();    /* Move input pool pointer into internal pointer.  */    pool =  (PM_PCB *) pool_ptr;#ifdef  NU_ENABLE_STACK_CHECK    /* Call stack checking function to check for an overflow condition.  */    TCT_Check_Stack();#endif#ifdef  NU_ENABLE_HISTORY    /* Make an entry that corresponds to this function in the system history       log.  */    HIC_Make_History_Entry(NU_DELETE_PARTITION_POOL_ID, (UNSIGNED) pool,                                        (UNSIGNED) 0, (UNSIGNED) 0);#endif    /* Protect against simultaneous access to the partition pool.  */    TCT_System_Protect();#ifdef INCLUDE_PROVIEW    _RTProf_DumpPartitionPool(RT_PROF_DELETE_PARTITION_POOL,pool,RT_PROF_OK);#endif /* INCLUDE_PROVIEW */    /* Clear the partition pool ID.  */    pool -> pm_id =  0;    /* Release protection.  */    TCT_Unprotect();    /* Protect against access to the list of created partition pools.  */    TCT_Protect(&PMD_List_Protect);    /* Remove the partition pool from the list of created partition pools.  */    CSC_Remove_From_List(&PMD_Created_Pools_List, &(pool -> pm_created));    /* Decrement the total number of created partition pools.  */    PMD_Total_Pools--;    /* Pickup the suspended task pointer list.  */    suspend_ptr =  pool -> pm_suspension_list;    /* Walk the chain task(s) currently suspended on the partition pool.  */    preempt =  0;    while (suspend_ptr)    {        /* Protect against system access.  */        TCT_System_Protect();        /* Resume the suspended task.  Insure that the status returned is           NU_POOL_DELETED.  */        suspend_ptr -> pm_return_pointer =  NU_NULL;        suspend_ptr -> pm_return_status =   NU_POOL_DELETED;        /* Point to the next suspend structure in the link.  */        next_ptr =  (PM_SUSPEND *) (suspend_ptr -> pm_suspend_link.cs_next);        /* Resume the specified task.  */        preempt =  preempt |            TCC_Resume_Task((NU_TASK *) suspend_ptr -> pm_suspended_task,                                                NU_PARTITION_SUSPEND);        /* Determine if the next is the same as the current pointer.  */        if (next_ptr == pool -> pm_suspension_list)            /* Clear the suspension pointer to signal the end of the list               traversal.  */            suspend_ptr =  NU_NULL;        else            /* Move the next pointer into the suspend block pointer.  */            suspend_ptr =  next_ptr;        /* Modify current protection.  */        TCT_Set_Current_Protect(&PMD_List_Protect);        /* Clear the system protection.  */        TCT_System_Unprotect();    }    /* Determine if preemption needs to occur.  */    if (preempt)        /* Transfer control to system to facilitate preemption.  */        TCT_Control_To_System();    /* Release protection against access to the list of created partition       pools. */    TCT_Unprotect();    /* Return to user mode */    NU_USER_MODE();    /* Return a successful completion.  */    return(NU_SUCCESS);}/*************************************************************************//*                                                                       *//* FUNCTION                                                              *//*                                                                       *//*      PMC_Allocate_Partition                                           *//*                                                                       *//* DESCRIPTION                                                           *//*                                                                       *//*      This function allocates a memory partition from the specified    *//*      memory partition pool.  If a memory partition is currently       *//*      available, this function is completed immediately.  Otherwise,   *//*      if there are no partitions currently available, suspension is    *//*      possible.                                                        *//*                                                                       *//* CALLED BY                                                             *//*                                                                       *//*      Application                                                      *//*      PMCE_Allocate_Partition             Error checking shell         *//*                                                                       *//* CALLS                                                                 *//*                                                                       *//*      CSC_Place_On_List                   Place on suspend list        *//*      CSC_Priority_Place_On_List          Place on priority list       *//*      [HIC_Make_History_Entry]            Make entry in history log    *//*      TCC_Suspend_Task                    Suspend calling task         *//*      TCC_Task_Priority                   Pickup task's priority       *//*      [TCT_Check_Stack]                   Stack checking function      *//*      TCT_Current_Thread                  Pickup current thread pointer*//*      TCT_System_Protect                  Protect partition pool       *//*      TCT_Unprotect                       Release protection           *//*                                                                       *//* INPUTS                                                                *//*                                                                       *//*      pool_ptr                            Memory partition pool pointer*//*      return_pointer                      Pointer to the destination   *//*                                            memory pointer             *//*      suspend                             Suspension option if full    *//*                                                                       *//* OUTPUTS                                                               *//*                                                                       *//*      NU_SUCCESS                          If service is successful     *//*      NU_NO_PARTITION                     No partitions are available  *//*      NU_TIMEOUT                          If timeout on service        *//*      NU_POOL_DELETED                     If partition pool deleted    *//*                                            during suspension          *//*                                                                       *//* HISTORY                                                               *//*                                                                       *//*        DATE                    REMARKS                                *//*                                                                       *//*      03-01-1993      Created initial version 1.0                      *//*      04-19-1993      Verified version 1.0                             *//*      03-01-1994      Changed function interfaces to                   *//*                      match those in prototype,                        *//*                      added register options, changed                  *//*                      protection logic to reduce                       *//*                      overhead, resulting in                           *//*                      version 1.1                                      *//*                                                                       *//*      03-18-1994      Verified version 1.1                             *//*                                                                       *//*************************************************************************/STATUS  PMC_Allocate_Partition(NU_PARTITION_POOL *pool_ptr,                                VOID **return_pointer, UNSIGNED suspend){R1 PM_PCB      *pool;                       /* Pool control block ptr    */R2 PM_SUSPEND  *suspend_ptr;                /* Suspend block pointer     */PM_SUSPEND      suspend_block;              /* Allocate suspension block */R3 PM_HEADER   *partition_ptr;              /* Pointer to partition      */TC_TCB         *task;                       /* Task pointer              */STATUS          status;                     /* Completion status         */NU_SUPERV_USER_VARIABLES    /* Switch to supervisor mode */    NU_SUPERVISOR_MODE();    /* Move input pool pointer into internal pointer.  */    pool =  (PM_PCB *) pool_ptr;#ifdef  NU_ENABLE_STACK_CHECK    /* Call stack checking function to check for an overflow condition.  */    TCT_Check_Stack();#endif#ifdef  NU_ENABLE_HISTORY    /* Make an entry that corresponds to this function in the system history       log.  */    HIC_Make_History_Entry(NU_ALLOCATE_PARTITION_ID, (UNSIGNED) pool,                                (UNSIGNED) return_pointer, (UNSIGNED) suspend);#endif    /* Initialize the status as successful.  */    status =  NU_SUCCESS;    /* Protect against simultaneous access to the partition pool.  */    TCT_System_Protect();    /* Determine if there is an available memory partition.  */    if (pool -> pm_available)    {        /* Partition available.  */        /* Decrement the available count.  */        pool -> pm_available--;        /* Increment the allocated count.  */        pool -> pm_allocated++;        /* Unlink the first memory partition and return the pointer to the           caller.  */        partition_ptr =              pool -> pm_available_list;        pool -> pm_available_list =  partition_ptr -> pm_next_available;        partition_ptr -> pm_next_available =  NU_NULL;        /* Return a memory address to the caller.  */        *return_pointer =  (VOID *) (((BYTE_PTR) partition_ptr) + PM_OVERHEAD);#ifdef INCLUDE_PROVIEW        _RTProf_DumpPartitionPool(RT_PROF_ALLOCATE_PARTITION,pool,RT_PROF_OK);#endif /* INCLUDE_PROVIEW */    }    else    {        /* A partition is not available.  Determine if suspension is           required. */        if (suspend)        {            /* Suspension is selected.  */            /* Increment the number of tasks waiting.  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -