| | 5 | == Description des deux tâches == |
| | 6 | |
| | 7 | Dans le nouveau répertoire, créez un répertoire `'src'` et allez dedans. |
| | 8 | |
| | 9 | Créez un fichier `producer.task` contenant: |
| | 10 | {{{ |
| | 11 | TaskModel( |
| | 12 | 'producer', |
| | 13 | ports = { 'output' : MwmrOutput(32) }, |
| | 14 | impl = [ |
| | 15 | SwTask('prod_func', |
| | 16 | stack_size = 2048, |
| | 17 | sources = ['producer.c']) |
| | 18 | ] ) |
| | 19 | }}} |
| | 20 | |
| | 21 | Créez un fichier `consumer.task` contenant: |
| | 22 | {{{ |
| | 23 | TaskModel( |
| | 24 | 'consumer', |
| | 25 | ports = { 'input' : MwmrInput(32) }, |
| | 26 | impl = [ |
| | 27 | SwTask('cons_func', |
| | 28 | stack_size = 2048, |
| | 29 | sources = ['consumer.c']) |
| | 30 | ] ) |
| | 31 | }}} |
| | 32 | |
| | 33 | == Implémentation des deux tâches == |
| | 34 | |
| | 35 | Toujours dans `'src'`, |
| | 36 | |
| | 37 | dans {{{producer.c}}}, mettez: |
| | 38 | |
| | 39 | {{{ |
| | 40 | #include <srl.h> |
| | 41 | #include "producer_proto.h" |
| | 42 | |
| | 43 | FUNC(prod_func) |
| | 44 | { |
| | 45 | srl_mwmr_t output = GET_ARG(output); |
| | 46 | char buf[32] = "...World"; |
| | 47 | srl_log_printf(NONE, "Producer : Hello...\n"); |
| | 48 | srl_mwmr_write(output, buf, 32); |
| | 49 | } |
| | 50 | }}} |
| | 51 | |
| | 52 | dans {{{consumer.c}}}, mettez: |
| | 53 | |
| | 54 | {{{ |
| | 55 | #include <srl.h> |
| | 56 | #include "consumer_proto.h" |
| | 57 | |
| | 58 | FUNC(cons_func) |
| | 59 | { |
| | 60 | srl_mwmr_t input = GET_ARG(input); |
| | 61 | char buf[32]; |
| | 62 | srl_mwmr_read(input, buf, 32); |
| | 63 | srl_log_printf(NONE, "Consumer : %s\n\n", buf); |
| | 64 | } |
| | 65 | }}} |
| | 66 | |
| | 67 | On vient de créer deux modèles de tâches (décris dans les fichiers `.task`, et leurs implémentations. |
| | 68 | |
| 59 | | == Fichier producer.c == |
| 60 | | |
| 61 | | Dans {{{producer.c}}}, mettez: |
| 62 | | |
| 63 | | {{{ |
| 64 | | #include <srl.h> |
| 65 | | #include "producer_proto.h" |
| 66 | | |
| 67 | | FUNC(prod_func) |
| 68 | | { |
| 69 | | srl_mwmr_t output = GET_ARG(output); |
| 70 | | char buf[32] = "...World"; |
| 71 | | srl_log_printf(NONE, "Producer : Hello...\n"); |
| 72 | | srl_mwmr_write(output, buf, 8); |
| 73 | | } |
| 74 | | }}} |
| 75 | | |
| 76 | | == Fichier consumer.c == |
| 77 | | |
| 78 | | Dans {{{consumer.c}}}, mettez: |
| 79 | | |
| 80 | | {{{ |
| 81 | | #include <srl.h> |
| 82 | | #include "consumer_proto.h" |
| 83 | | |
| 84 | | FUNC(cons_func) |
| 85 | | { |
| 86 | | srl_mwmr_t input = GET_ARG(input); |
| 87 | | char buf[32]; |
| 88 | | srl_mwmr_read(input, buf, 8); |
| 89 | | srl_log_printf(NONE, "Consumer : %s\n\n", buf); |
| 90 | | } |
| 91 | | }}} |
| 92 | | |
| 93 | | |