📄 pic.c
字号:
/* CALLED BY *//* *//* Application *//* PICE_Delete_Pipe 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 Protect against system access*//* TCT_System_Unprotect Release system protection *//* TCT_Unprotect Release protection *//* *//* INPUTS *//* *//* pipe_ptr Pipe 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 PIC_Delete_Pipe(NU_PIPE *pipe_ptr){R1 PI_PCB *pipe; /* Pipe control block ptr */PI_SUSPEND *suspend_ptr; /* Suspend block pointer */PI_SUSPEND *next_ptr; /* Next suspension block ptr */STATUS preempt; /* Status for resume call */NU_SUPERV_USER_VARIABLES /* Switch to supervisor mode */ NU_SUPERVISOR_MODE(); /* Move input pipe pointer into internal pointer. */ pipe = (PI_PCB *) pipe_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_PIPE_ID, (UNSIGNED) pipe, (UNSIGNED) 0, (UNSIGNED) 0);#endif /* Protect against access to the pipe. */ TCT_System_Protect();#ifdef INCLUDE_PROVIEW _RTProf_DumpPipe(RT_PROF_DELETE_PIPE,pipe,RT_PROF_OK);#endif /* INCLUDE_PROVIEW */ /* Clear the pipe ID. */ pipe -> pi_id = 0; /* Release protection. */ TCT_Unprotect(); /* Protect against access to the list of created pipes. */ TCT_Protect(&PID_List_Protect); /* Remove the pipe from the list of created pipes. */ CSC_Remove_From_List(&PID_Created_Pipes_List, &(pipe -> pi_created)); /* Decrement the total number of created pipes. */ PID_Total_Pipes--; /* Pickup the suspended task pointer list. */ suspend_ptr = pipe -> pi_suspension_list; /* Walk the chain task(s) currently suspended on the pipe. */ preempt = 0; while (suspend_ptr) { /* Protect against system access. */ TCT_System_Protect(); /* Resume the suspended task. Insure that the status returned is NU_PIPE_DELETED. */ suspend_ptr -> pi_return_status = NU_PIPE_DELETED; /* Point to the next suspend structure in the link. */ next_ptr = (PI_SUSPEND *) (suspend_ptr -> pi_suspend_link.cs_next); /* Resume the specified task. */ preempt = preempt | TCC_Resume_Task((NU_TASK *) suspend_ptr -> pi_suspended_task, NU_PIPE_SUSPEND); /* Determine if the next is the same as the head pointer. */ if (next_ptr == pipe -> pi_suspension_list) /* Clear the suspension pointer to signal the end of the list traversal. */ suspend_ptr = NU_NULL; else /* Setup the next suspension pointer. */ suspend_ptr = next_ptr; /* Modify current protection. */ TCT_Set_Current_Protect(&PID_List_Protect); /* Clear the system protection. */ TCT_System_Unprotect(); } /* Pickup the urgent message suspension list. */ suspend_ptr = pipe -> pi_urgent_list; /* Walk the chain task(s) currently suspended on the pipe. */ while (suspend_ptr) { /* Protect against system access. */ TCT_System_Protect(); /* Resume the suspended task. Insure that the status returned is NU_PIPE_DELETED. */ suspend_ptr -> pi_return_status = NU_PIPE_DELETED; /* Point to the next suspend structure in the link. */ next_ptr = (PI_SUSPEND *) (suspend_ptr -> pi_suspend_link.cs_next); /* Resume the specified task. */ preempt = preempt | TCC_Resume_Task((NU_TASK *) suspend_ptr -> pi_suspended_task, NU_PIPE_SUSPEND); /* Determine if the next is the same as the head pointer. */ if (next_ptr == pipe -> pi_urgent_list) /* Clear the suspension pointer to signal the end of the list traversal. */ suspend_ptr = NU_NULL; else /* Position suspend pointer to the next block. */ suspend_ptr = next_ptr; /* Modify current protection. */ TCT_Set_Current_Protect(&PID_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 pipes. */ TCT_Unprotect(); /* Return to user mode */ NU_USER_MODE(); /* Return a successful completion. */ return(NU_SUCCESS);}/*************************************************************************//* *//* FUNCTION *//* *//* PIC_Send_To_Pipe *//* *//* DESCRIPTION *//* *//* This function sends a message to the specified pipe. The *//* message length is determined by the caller. If there are one *//* or more tasks suspended on the pipe for a message, the message *//* is copied into the message area of the first waiting task. If *//* the task's request is satisfied, it is resumed. Otherwise, if *//* the pipe cannot hold the message, suspension of the calling *//* task is an option of the caller. *//* *//* CALLED BY *//* *//* Application *//* PICE_Send_To_Pipe Error checking shell *//* *//* CALLS *//* *//* CSC_Place_On_List Place on suspend list *//* CSC_Priority_Place_On_List Place on priority list *//* CSC_Remove_From_List Remove from suspend list *//* [HIC_Make_History_Entry] Make entry in history log *//* TCC_Resume_Task Resume a suspended task *//* TCC_Suspend_Task Suspend calling task *//* TCC_Task_Priority Pickup task's priority *//* [TCT_Check_Stack] Stack checking function *//* TCT_Control_To_System Transfer control to system *//* TCT_Current_Thread Pickup current thread pointer*//* TCT_System_Protect Protect pipe *//* TCT_Unprotect Release protection *//* *//* INPUTS *//* *//* pipe_ptr Pipe control block pointer *//* message Pointer to message to send *//* size Size of message to send *//* suspend Suspension option if full *//* *//* OUTPUTS *//* *//* NU_SUCCESS If service is successful *//* NU_PIPE_FULL If pipe is currently full *//* NU_TIMEOUT If timeout on service expires*//* NU_PIPE_DELETED If pipe was deleted during *//* suspension *//* NU_PIPE_RESET If pipe was reset 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, optimized copy loop, *//* resulting in version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* *//*************************************************************************/STATUS PIC_Send_To_Pipe(NU_PIPE *pipe_ptr, VOID *message, UNSIGNED size, UNSIGNED suspend){R1 PI_PCB *pipe; /* Pipe control block ptr */PI_SUSPEND suspend_block; /* Allocate suspension block */PI_SUSPEND *suspend_ptr; /* Pointer to suspend block */R2 BYTE_PTR source; /* Pointer to source */R3 BYTE_PTR destination; /* Pointer to destination */UNSIGNED copy_size; /* Partial copy size */R4 INT i; /* Working counter */UNSIGNED pad = 0; /* Number of pad bytes */TC_TCB *task; /* Task pointer */STATUS preempt; /* Preempt flag */STATUS status; /* Completion status */NU_SUPERV_USER_VARIABLES /* Switch to supervisor mode */ NU_SUPERVISOR_MODE(); /* Move input pipe pointer into internal pointer. */ pipe = (PI_PCB *) pipe_ptr;#ifdef NU_ENABLE_STACK_CHECK /* Call stack checking function to check for an overflow condition. */ TCT_Check_Stack();#endif#ifdef NU_ENABLE_HISTORY
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -