Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Renamed host to cpu. That was really confusing.
[simgrid.git] / src / surf / surf.c
1 /* Authors: Arnaud Legrand                                                  */
2
3 /* This program is free software; you can redistribute it and/or modify it
4    under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "surf_private.h"
7 #include "cpu_private.h"
8
9 s_surf_global_t surf_global;
10
11 e_surf_action_state_t surf_action_get_state(surf_action_t action)
12 {
13   if(action->state_set == surf_global.ready_action_set)
14     return SURF_ACTION_READY;
15   if(action->state_set == surf_global.running_action_set)
16     return SURF_ACTION_RUNNING;
17   if(action->state_set == surf_global.failed_action_set)
18     return SURF_ACTION_FAILED;
19   if(action->state_set == surf_global.done_action_set)
20     return SURF_ACTION_DONE;
21   return SURF_ACTION_NOT_IN_THE_SYSTEM;
22 }
23
24 void surf_action_free(surf_action_t * action)
25 {
26   (*action)->resource_type->action_cancel(*action);
27   xbt_free(*action);
28   *action=NULL;
29 }
30
31 void surf_action_change_state(surf_action_t action, e_surf_action_state_t state)
32 {
33   xbt_swag_extract(action, action->state_set);
34   if(state == SURF_ACTION_READY) 
35     action->state_set = surf_global.ready_action_set;
36   else if(state == SURF_ACTION_RUNNING)
37     action->state_set = surf_global.running_action_set;
38   else if(state == SURF_ACTION_FAILED)
39     action->state_set = surf_global.failed_action_set;
40   else if(state == SURF_ACTION_DONE)
41     action->state_set = surf_global.done_action_set;
42   else action->state_set = NULL;
43
44   if(action->state_set) xbt_swag_insert(action, action->state_set);
45 }
46
47 void surf_init(void)
48 {
49   surf_cpu_resource = surf_cpu_resource_init();
50 }
51
52 /* xbt_heap_float_t surf_solve(void) */
53 /* { */
54 /* } */
55