Skip to content

Commit

Permalink
random excercise
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve2955 committed Oct 27, 2021
1 parent 38c8920 commit 17bdcd1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions RES-GUENTHER/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ Systemprogrammierung / Verteilte Systeme

> **Fünf-Philosophen-Problem**
>
> Es können immer nur zwei Philosophen speisen
> ...
> [siehe Wikipedia](https://de.wikipedia.org/wiki/Philosophenproblem)
>
> Es können immer nur maximal zwei Philosophen gleichzeitig speisen
### Prozesssteuerung

Expand Down
22 changes: 22 additions & 0 deletions RES-GUENTHER/extra/excercise-02/prozess-anton.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<unistd.h>
#include<sys/types.h>

void active_wait(int cycles){
for(int x=0; x < cycles; x++){
for(int y=0; y < cycles; y++){
y++; y--;
}
}
}

int main(int argc, const char* argv[]){
srand(time(NULL) ^ getpid());
for(int i = rand() % 55 + 2; i > 0; i--){
printf("%d. Hallo, ich bin %s und ich melde mich gleich wieder.\n", i, argc >= 2 ? argv[1] : "Anton");
active_wait(10000);
}
return 0;
}

0 comments on commit 17bdcd1

Please sign in to comment.