sched/scheduler.c
/**************************************************************************
* Name:
* sched_allocate_resource
*
* Description:
*  Allocate a new resource and store the file desscriptor in the resource
*  structure.
*
* Return Value:
*  The opened container resource or NULL in case we are running out of memory.
*
*************************************************************************/


Allocate a new resource and store the file desscriptor in the resource
structure.

Return Value:
The opened container resource or NULL in case we are running out of memory.
Allocate a new resource and store the file desscriptor in the resource structure . Return Value : The opened container resource or NULL in case we are running out of memory .
struct opened_resource_s *sched_allocate_resource(const struct vfs_node_s *vfs_node,
                                                  int open_mode)
{
  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 *new_res = calloc(1,
      sizeof(struct opened_resource_s));
  if (!new_res) {
    cpu_enableint(irq_state);
    return NULL;
  }
  new_res->fd        = curr_tcb->curr_resource_opened;
  new_res->open_mode = open_mode;
  new_res->vfs_node  = (struct vfs_node_s *)vfs_node;
  curr_tcb->curr_resource_opened++;
  list_add(&new_res->node, &curr_tcb->opened_resource);
  cpu_enableint(irq_state);
  return new_res;
}
struct opened_resource_s * sched_allocate_resource ( const struct vfs_node_s * vfs_node , int open_mode ) { 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 * new_res = calloc ( 1 , sizeof ( struct opened_resource_s ) ) ; if ( ! new_res ) { cpu_enableint ( irq_state ) ; return NULL ; } new_res -> fd = curr_tcb -> curr_resource_opened ; new_res -> open_mode = open_mode ; new_res -> vfs_node = ( struct vfs_node_s * ) vfs_node ; curr_tcb -> curr_resource_opened ++ ; list_add ( & new_res -> node , & curr_tcb -> opened_resource ) ; cpu_enableint ( irq_state ) ; return new_res ; }
Name:
sched_allocate_resource
Name : sched_allocate_resource