Revision 17d978fe src/urt_node.c

View differences:

src/urt_node.c
37 37
/* LOCAL VARIABLES                                                            */
38 38
/******************************************************************************/
39 39

  
40
urt_node_t localNode; //TODO:Correct?
41

  
40 42
/******************************************************************************/
41 43
/* LOCAL FUNCTIONS                                                            */
42 44
/******************************************************************************/
43 45

  
46
/**
47
 * @brief  Main function of a node.
48
 *
49
 * @param[in] arg  Optional Argument to the thread main function.
50
 */
51
void _main(void* arg)
52
{
53
    //TODO: Register to core event
54
    if (localNode.setupcallback != NULL)
55
    {
56
        // urt_osEventMask_t mask = localNode.setupcallback(localNode, arg);
57
        // TODOs
58
    }
59
    else
60
    {
61
        //TODO: act as if setupcallback returned 0xF..F
62
    }
63
    if (core._status == URT_STATUS_OK)
64
    {
65
        //TODO: Suspend all child threads
66
        urtCoreSynchronizeNodes(&localNode);
67
        //TODO: Resume all child threads
68
    }
69
    //TODOs
70
    return;
71
}
72

  
44 73
/******************************************************************************/
45 74
/* EXPORTED FUNCTIONS                                                         */
46 75
/******************************************************************************/
47 76

  
48 77
/**
49
 * @brief  Initalize the node.
78
 * @brief  Initalize a node.
50 79
 *
51 80
 * @param[in] node  The node to initialize. Must not be NULL.
52 81
 * @param[in] thread  The already initialized, exclusive thread for the node. Must not be NULL.
......
69 98
                 void* setupparams, urt_nodeLoopCallback_t* loopcallback, void* loopparams,
70 99
                 urt_nodeShutdownCallback_t* shutdowncallback, void* shutdownparams)
71 100
{
101
  urtDebugAssert(node != NULL);
102
  urtDebugAssert(thread != NULL);
103
  //TODO: Setupcallback
104
  if (setupcallback == NULL)
105
    urtDebugAssert(setupparams == NULL);
106
  urtDebugAssert(loopcallback != NULL);
107
  //urtDebugAssert(/*loopparams*/);
108
  //urtDebugAssert(shutdowncallback);
109
  //urtDebugAssert(shutdownparams);
110

  
72 111
  node->next = NULL;
73 112
  node->thread = thread;
74 113
  node->setupcallback = setupcallback;
......
82 121
  #if (URT_CFG_PUBSUB_PROFILING || URT_CFG_RPC_PROFILING)
83 122
    node->loops = 0;
84 123
  #endif /* URT_CFG_PUBSUB_PROFILING || URT_CFG_RPC_PROFILING */
85
  urt_core_t temp; //TODO: Correct?
86
  urtMutexLock(&temp._lock);
87
    node->next = temp._nodes;
88
    temp._nodes = node;
89
  urtMutexUnlock(&temp._lock);
124
  urtMutexLock(&core._lock);
125
    node->next = core._nodes;
126
    core._nodes = node;
127
  urtMutexUnlock(&core._lock);
128
  localNode = *node;
90 129
  return;
91 130
}

Also available in: Unified diff