This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* We have two sides which can lock our vmutexes: | |
* 1st side uses acquire/release functions and it can only hold mutex when | |
* `counter` is zero. If counter is not zero `acquire` waits. | |
* 2nd side uses increment/decrement functions and when it holds mutex it | |
* increments `counter`. This side can't hold mutex while 1st side is already | |
* holding it. | |
*/ | |
#include <pthread.h> | |
#include <stdlib.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parse_line(char *line) | |
{ | |
int i; | |
char *key; | |
char *value; | |
for (i = 0; line[i] != '\0'; i++) { | |
if (line[i] == ' ') { | |
/* jump spaces */ | |
while (line[i] == ' ') |