📄 nufp.c
字号:
/************************************************************************
*
* Copyright (c) 2001 by Accelerated Technology, Inc.
*
* PROPRIETARY RIGHTS of Accelerated Technology are involved in
* the subject matter of this material. All manufacturing,
* reproduction, use, and sales rights pertaining to this subject
* matter are governed by the license agreement. The recipient of
* this software implicitly accepts the terms of the license.
*
*
*************************************************************************
*************************************************************************
* FILE NAME VERSION
*
* NUFP.C FILE 2.3
*
* COMPONENT
*
* Nucleus File
*
* DESCRIPTION
*
* This file contains the routines necessary to intitialize
* the Nucleus PLUS environment for file system usage.
*
* DATA STRUCTURES
*
* NUFP_TASK_POINTER Task ID list.
*
* FUNCTIONS
*
* NUFP_Current_Task_ID Replaces the Nucleus PLUS
* Task Pointer to a Task ID.
* NUFP_Remove_User Responsible from removing a
* user from the
* NUFP_TASK_POINTER table.
*
* DEPENDENCIES
*
* nucleus.h System definitions
* pcdisk.h File common definitions
*
*************************************************************************/
#include "plus\nucleus.h"
#include "file\pcdisk.h"
#if (RAMDISK)
#if (!RAMDISK_FROMPOOL)
#include <malloc.h>
#endif
#endif
/* The following table maintains a mapping between Nucleus PLUS pointers
and Task IDs. */
NU_TASK *NUFP_TASK_POINTER[NUM_USERS];
/* The following declarations are used for intialization of the Nucleus
PLUS tasking environment for the Nucleus FILE system. */
/************************************************************************
* FUNCTION
*
* NUFP_Current_Task_ID
*
* DESCRIPTION
*
* This function convert a Task Pointer to a Task ID.
*
*
* AUTHOR
*
* Neil F. Henderson, Accelerated Technology, Inc.
*
* INPUTS
*
* None.
*
* OUTPUTS
*
* task_id The id of the task that
* represents the task pointer.
*
*************************************************************************/
INT NUFP_Current_Task_ID(VOID)
{
NU_TASK *current_task_ptr;
INT task_id;
/* Intialize the task_id. */
task_id = 0;
/* Get the Task Pointer to the current task. */
current_task_ptr = NU_Current_Task_Pointer();
/* Search for the Task Pointer. */
for (task_id = 0; task_id < NUM_USERS; task_id++)
{
/* If we found the entry, then return the ID. */
if (NUFP_TASK_POINTER[task_id] == current_task_ptr)
return(task_id);
}
/* There is not one already established, so find a blank spot,
set up the pointer, and return the ID. */
for (task_id = 0; task_id < NUM_USERS; task_id++)
{
/* If we found a blank entry, then return the ID. */
if (NUFP_TASK_POINTER[task_id] == NU_NULL)
{
/* Save the entry so that we find it next time. */
NUFP_TASK_POINTER[task_id] = current_task_ptr;
/* Return the associated ID. */
return(task_id);
}
}
/* We did not find an empty entry for a new task. That means that the
user did a no no. We need to invoke some kind of error handler here. */
return(-1);
} /* end of NUFP_Current_Task_ID. */
/************************************************************************
* FUNCTION
*
* NUFP_Remove_User
*
* DESCRIPTION
*
* This function is responsible from removing a user from the
* NUFP_TASK_POINTER table.
*
* AUTHOR
*
* Neil F. Henderson, Accelerated Technology, Inc.
*
* INPUTS
*
* task_id Converted task ID from PLUS
* task pointer
*
* OUTPUTS
*
* NUFP_TASK_POINTER Updated to remove the task
* pointed to by the ID.
*
*************************************************************************/
VOID NUFP_Remove_User(INT task_id)
{
/* Remove the task pointer. */
NUFP_TASK_POINTER[task_id] = NU_NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -