C : simply sema
\ntypedef struct {\n    sem_t fsema, bsema;\n    int n;\n} FooBar;\n\nFooBar* fooBarCreate(int n) {\n    FooBar* obj = (FooBar*) malloc(sizeof(FooBar));\n    se
```\ntypedef struct {\n    sem_t fsema, bsema;\n    int n;\n} FooBar;\n\nFooBar* fooBarCreate(int n) {\n    FooBar* obj = (FooBar*) malloc(sizeof(FooBar));\n    sem_init(&obj->fsema, 0, 1);\n    sem_init(&obj->bsema, 0, 0);\n    obj->n = n;\n    return obj;\n}\n\nvoid foo(FooBar* obj) {\n    for (int i = 0; i < obj->n; i++) {\n        sem_wait(&obj->fsema);        \n        printFoo();\n        sem_post(&obj->bsema);\n    }\n}\n\nvoid bar(FooBar* obj) {\n    for (int i = 0; i < obj->n; i++) {\n        sem_wait(&obj->bsema);                \n        printBar();\n        sem_post(&obj->fsema);\n    }\n}\n\nvoid fooBarFree(FooBar* obj) {\n    sem_destroy(&obj->fsema);\n    sem_destroy(&obj->bsema);\n    free(obj);\n}\n```
['C']