Ignore:
Timestamp:
Oct 1, 2015, 4:20:46 PM (9 years ago)
Author:
alain
Message:

Major release: Change the task model to implement the POSIX threads API.

  • The shell "exec" and "kill" commands can be used to activate/de-activate the applications.
  • The "pause", "resume", and "context" commands can be used to stop, restart, a single thtead or to display the thread context.

This version has been tested on the following multi-threaded applications,
that have been modified to use the POSIX threads:

  • classif
  • convol
  • transpose
  • gameoflife
  • raycast
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_xml/xml_parser.c

    r645 r709  
    1111// 1) the multi-cluster/multi-processors hardware architecture description
    1212// 2) the various multi-threaded software applications
    13 // 3) the mapping directives bor both the tasks and the virtual segments.
     13// 3) the mapping directives bor both the threads and the virtual segments.
    1414// The corresponding C structures are defined in the "mapping_info.h" file.
    1515///////////////////////////////////////////////////////////////////////////////////////
     
    3131#define MAX_PSEGS      4096
    3232#define MAX_VSPACES    1024
    33 #define MAX_TASKS      4096
     33#define MAX_THREADS      4096
    3434#define MAX_VSEGS      4096
    3535#define MAX_PROCS      1024
     
    4848mapping_vspace_t *   vspace[MAX_VSPACES];    // vspace array
    4949mapping_vseg_t *     vseg[MAX_VSEGS];        // vseg array
    50 mapping_task_t *     task[MAX_TASKS];        // task array
     50mapping_thread_t *   thread[MAX_THREADS];      // thread array
    5151mapping_proc_t *     proc[MAX_PROCS];        // proc array
    5252mapping_irq_t *      irq[MAX_IRQS];          // irq array
     
    7272unsigned int vseg_loc_index = 0;
    7373
    74 unsigned int task_index = 0;
    75 unsigned int task_loc_index = 0;
     74unsigned int thread_index = 0;
     75unsigned int thread_loc_index = 0;
    7676
    7777
     
    275275
    276276
    277 //////////////////////////////////////
    278 void taskNode(xmlTextReaderPtr reader)
     277////////////////////////////////////////
     278void threadNode(xmlTextReaderPtr reader)
    279279{
    280280    unsigned int ok;
     
    285285    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
    286286
    287     if (task_index >= MAX_TASKS)
    288     {
    289         printf("[XML ERROR] The number of tasks is larger than %d\n", MAX_TASKS);
    290         exit(1);
    291     }
    292 
    293 #if XML_PARSER_DEBUG
    294 printf("   task %d\n", task_loc_index);
    295 #endif
    296 
    297     task[task_index] = (mapping_task_t *) malloc(sizeof(mapping_task_t));
     287    if (thread_index >= MAX_THREADS)
     288    {
     289        printf("[XML ERROR] The number of threads is larger than %d\n", MAX_THREADS);
     290        exit(1);
     291    }
     292
     293#if XML_PARSER_DEBUG
     294printf("   thread %d\n", thread_loc_index);
     295#endif
     296
     297    thread[thread_index] = (mapping_thread_t *) malloc(sizeof(mapping_thread_t));
    298298
    299299    ////////// get name attribute
     
    304304printf("      name      = %s\n", str);
    305305#endif
    306         strncpy( task[task_index]->name, str, 31 );
    307     }
    308     else
    309     {
    310         printf("[XML ERROR] illegal or missing <name> attribute for task (%d,%d)\n",
    311                 vspace_index, task_loc_index);
    312         exit(1);
    313     }
    314 
    315     ///////// get trdid attribute (optional)
    316     value = getIntValue(reader, "trdid", &ok);
    317 #if XML_PARSER_DEBUG
    318 printf("      trdid     = %d\n", value );
    319 #endif
    320     if ( ok ) task[task_index]->trdid = value;
    321     else      task[task_index]->trdid = task_loc_index;
     306        strncpy( thread[thread_index]->name, str, 31 );
     307    }
     308    else
     309    {
     310        printf("[XML ERROR] illegal or missing <name> for thread %d in vspace %d\n",
     311                thread_loc_index, vspace_index);
     312        exit(1);
     313    }
     314
     315    ///////// get is_main attribute
     316    value = getIntValue(reader, "is_main", &ok);
     317    if ( ok )
     318    {
     319#if XML_PARSER_DEBUG
     320printf("      is_main   = %d\n", value );
     321#endif
     322        thread[thread_index]->is_main = value;
     323    }
     324    else
     325    {
     326        printf("[XML ERROR] illegal or missing <is_main> for thread %d in vspace %d\n",
     327                thread_loc_index, vspace_index);
     328    }
    322329
    323330    ///////// get x coordinate
     
    328335    if ( !(ok && (x < header->x_size)) )
    329336    {
    330         printf("[XML ERROR] illegal or missing < x > attribute for task (%d,%d)\n",
    331                 vspace_index, task_loc_index);
     337        printf("[XML ERROR] illegal or missing < x > for thread %d in vspace %d)\n",
     338                thread_loc_index, vspace_index);
    332339        exit(1);
    333340    } 
     
    340347    if ( !(ok && (y < header->y_size)) )
    341348    {
    342         printf("[XML ERROR] illegal or missing < y > attribute for task (%d,%d)\n",
    343                 vspace_index, task_loc_index);
     349        printf("[XML ERROR] illegal or missing < y > for thread %d in vspace %d)\n",
     350                thread_loc_index, vspace_index);
    344351        exit(1);
    345352    } 
     
    352359    if( index >= 0 )
    353360    {
    354         task[task_index]->clusterid = index;
     361        thread[thread_index]->clusterid = index;
    355362    }
    356363    else
    357364    {
    358         printf("[XML ERROR] <clusterid> not found for task (%d,%d)\n",
    359                 vspace_index, task_loc_index);
     365        printf("[XML ERROR] <clusterid> not found for thread %d in vspace %d)\n",
     366                thread_loc_index, vspace_index);
    360367        exit(1);
    361368    }
     
    368375printf("      proclocid = %x\n", value);
    369376#endif
    370         if (value >= cluster[task[task_index]->clusterid]->procs)
    371         {
    372             printf("[XML ERROR] <proclocid> too large for task (%d,%d)\n",
    373                     vspace_index, task_loc_index);
     377        if (value >= cluster[thread[thread_index]->clusterid]->procs)
     378        {
     379            printf("[XML ERROR] <proclocid> too large for thread %d in vspace %d\n",
     380                    thread_loc_index, vspace_index);
    374381            exit(1);
    375382        }
    376         task[task_index]->proclocid = value;
     383        thread[thread_index]->proclocid = value;
    377384    } 
    378385    else
    379386    {
    380         printf("[XML ERROR] illegal or missing <p> attribute for task (%d,%d)\n",
    381                 vspace_index, task_loc_index);
     387        printf("[XML ERROR] illegal or missing < p > for thread %d in vspace %d)\n",
     388                thread_loc_index, vspace_index);
    382389        exit(1);
    383390    }
     
    396403printf("      stack_id  = %d\n", index);
    397404#endif
    398             task[task_index]->stack_vseg_id = index;
     405            thread[thread_index]->stack_vseg_id = index;
    399406        }
    400407        else
    401408        {
    402             printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n",
    403                     vspace_index, task_loc_index);
     409            printf("[XML ERROR] illegal or missing <stackname> for thread %d in vspace %d)\n",
     410                    thread_loc_index, vspace_index);
    404411            exit(1);
    405412        }
     
    407414    else
    408415    {
    409         printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n",
    410                 vspace_index, task_loc_index);
     416        printf("[XML ERROR] illegal or missing <stackname> for thread %d in vspace %d)\n",
     417                thread_loc_index, vspace_index);
    411418        exit(1);
    412419    }
     
    425432printf("      heap_id   = %d\n", index );
    426433#endif
    427             task[task_index]->heap_vseg_id = index;
     434            thread[thread_index]->heap_vseg_id = index;
    428435        }
    429436        else
    430437        {
    431             printf("[XML ERROR] illegal or missing <heapname> for task (%d,%d)\n",
    432                    vspace_index, task_loc_index);
     438            printf("[XML ERROR] illegal or missing <heapname> for thread %d in vspace %d)\n",
     439                   thread_loc_index, vspace_index);
    433440            exit(1);
    434441        }
     
    436443    else
    437444    {
    438         task[task_index]->heap_vseg_id = -1;
     445        thread[thread_index]->heap_vseg_id = -1;
    439446    }
    440447
     
    446453printf("      startid   = %x\n", value);
    447454#endif
    448         task[task_index]->startid = value;
     455        thread[thread_index]->startid = value;
    449456    } 
    450457    else
    451458    {
    452         printf("[XML ERROR] illegal or missing <startid> attribute for task (%d,%d)\n",
    453                 vspace_index, task_loc_index);
    454         exit(1);
    455     }
    456 
    457     task_index++;
    458     task_loc_index++;
    459 } // end taskNode()
     459        printf("[XML ERROR] illegal or missing <startid> for thread %d in vspace %d\n",
     460                thread_loc_index, vspace_index);
     461        exit(1);
     462    }
     463
     464    thread_index++;
     465    thread_loc_index++;
     466} // end threadNode()
    460467
    461468
     
    698705    unsigned int ok;
    699706
    700     vseg_loc_index = 0;
    701     task_loc_index = 0;
     707    vseg_loc_index   = 0;
     708    thread_loc_index = 0;
    702709
    703710    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
     
    727734    else    vspace[vspace_index]->active = 0;
    728735   
    729     ////////// set vseg_offset and task_offset attributes
     736    ////////// set vseg_offset and thread_offset attributes
    730737    vspace[vspace_index]->vseg_offset = vseg_index;
    731     vspace[vspace_index]->task_offset = task_index;
    732 
    733     ////////// initialise vsegs and tasks attributes
     738    vspace[vspace_index]->thread_offset = thread_index;
     739
     740    ////////// initialise vsegs and threads attributes
    734741    vspace[vspace_index]->vsegs = 0;
    735     vspace[vspace_index]->tasks = 0;
     742    vspace[vspace_index]->threads = 0;
    736743
    737744    ////////// get startname attribute
     
    754761            vspace[vspace_index]->vsegs += 1;
    755762        }
    756         else if (strcmp(tag, "task") == 0)
    757         {
    758             taskNode(reader);
    759             vspace[vspace_index]->tasks += 1;
     763        else if (strcmp(tag, "thread") == 0)
     764        {
     765            threadNode(reader);
     766            vspace[vspace_index]->threads += 1;
    760767        }
    761768        else if (strcmp(tag, "#text")    == 0) { }
     
    777784
    778785#if XML_PARSER_DEBUG
    779 printf("      vsegs       = %d\n", vspace[vspace_index]->vsegs );
    780 printf("      tasks       = %d\n", vspace[vspace_index]->tasks );
    781 printf("      vseg_offset = %d\n", vspace[vspace_index]->vseg_offset );
    782 printf("      task_offset = %d\n", vspace[vspace_index]->task_offset );
    783 printf("      start_id    = %d\n", vspace[vspace_index]->start_vseg_id );
    784 printf("      active      = %x\n", vspace[vspace_index]->active );
     786printf("      vsegs         = %d\n", vspace[vspace_index]->vsegs );
     787printf("      threads       = %d\n", vspace[vspace_index]->threads );
     788printf("      vseg_offset   = %d\n", vspace[vspace_index]->vseg_offset );
     789printf("      thread_offset = %d\n", vspace[vspace_index]->thread_offset );
     790printf("      start_id      = %d\n", vspace[vspace_index]->start_vseg_id );
     791printf("      active        = %x\n", vspace[vspace_index]->active );
    785792printf("  end vspace %d\n\n", vspace_index);
    786793#endif
     
    14881495        {
    14891496            header->vsegs = vseg_index;
    1490             header->tasks = task_index;
     1497            header->threads = thread_index;
    14911498            return;
    14921499        }
     
    16681675    header->psegs     = 0;
    16691676    header->vsegs     = 0;
    1670     header->tasks     = 0;
     1677    header->threads   = 0;
    16711678    header->procs     = 0;
    16721679    header->irqs      = 0;
     
    17651772printf("psegs     = %d\n", header->psegs);
    17661773printf("vsegs     = %d\n", header->vsegs);
    1767 printf("tasks     = %d\n", header->tasks);
     1774printf("threads   = %d\n", header->threads);
    17681775printf("procs     = %d\n", header->procs);
    17691776printf("irqs      = %d\n", header->irqs);
     
    17871794    // write vsegs
    17881795    BuildTable(fdout, "vseg", vseg_index, sizeof(mapping_vseg_t), (char **) vseg);
    1789     // write tasks array
    1790     BuildTable(fdout, "task", task_index, sizeof(mapping_task_t), (char **) task);
     1796    // write threads array
     1797    BuildTable(fdout, "thread", thread_index, sizeof(mapping_thread_t), (char **) thread);
    17911798    //building procs array
    17921799    BuildTable(fdout, "proc", proc_index, sizeof(mapping_proc_t), (char **) proc);
Note: See TracChangeset for help on using the changeset viewer.