sched/scheduler.c
/**************************************************************************
 * Name:
 *  sched_free_resource
 *
 * Description:
 *  This method tears down the resources allocated for an object that has been
 *  opened. It should be called from close() context.
 *
 * Assumptions:
 *  Call this function with pre-emption disabled.
 *
 * Return Value:
 *  OK or a negative value on failure.
 *
 *************************************************************************/


This method tears down the resources allocated for an object that has been
opened. It should be called from close() context.

Call this function with pre-emption disabled.

Return Value:
OK or a negative value on failure.
This method tears down the resources allocated for an object that has been opened . It should be called from close () context . Call this function with pre - emption disabled . Return Value : OK or a negative value on failure .
int sched_free_resource(int fd)
{
  irq_state_t irq_state = cpu_disableint();
  struct tcb_s *curr_tcb = sched_get_current_task();
  assert(curr_tcb->curr_resource_opened >= 0);
  struct opened_resource_s *resource = sched_find_opened_resource(fd);
  if (resource) {
    list_del(&resource->node);
    free(resource);
    cpu_enableint(irq_state);
    return OK;
  }
  cpu_enableint(irq_state);
  return -ENOENT;
}
int sched_free_resource ( int fd ) { irq_state_t irq_state = cpu_disableint ( ) ; struct tcb_s * curr_tcb = sched_get_current_task ( ) ; assert ( curr_tcb -> curr_resource_opened >= 0 ) ; struct opened_resource_s * resource = sched_find_opened_resource ( fd ) ; if ( resource ) { list_del ( & resource -> node ) ; free ( resource ) ; cpu_enableint ( irq_state ) ; return OK ; } cpu_enableint ( irq_state ) ; return - ENOENT ; }
Name:
  sched_free_resource
Name : sched_free_resource
/* Iterate over opened resource list find the fd and free the resource */