This commit is contained in:
biosvos
2026-08-07 17:38:18 +09:00
commit 873193a243
9613 changed files with 2755992 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>
char buffer[1024];
sem_t bin_sem;
void *thread_func(void *arg)
{
while(1)
{
sem_wait(&bin_sem);
printf("you typed : %s\n", buffer);
}
}
int main()
{
pthread_t a_thread;
sem_init(&bin_sem, 0, 1);
pthread_create(&a_thread, 0, thread_func, 0);
while(1)
{
fgets(buffer, 1024, stdin);
sem_post(&bin_sem);
}
exit(1);
}