fix errors

This commit is contained in:
Mylloon 2024-04-23 12:21:10 +02:00
parent dab0c3a30e
commit 83295f16ca
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,12 +1,18 @@
#include "../includes/sched.h"
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
/* Routine d'un thread */
void *sched_worker(void *);
int
sched_init(int nthreads, int qlen, taskfunc f, void *closure)
{
// Paramètres inutilisés
(void)nthreads;
(void)qlen;
sched_spawn(f, closure, NULL);
return 0;
}
@ -14,21 +20,32 @@ sched_init(int nthreads, int qlen, taskfunc f, void *closure)
int
sched_spawn(taskfunc f, void *closure, struct scheduler *s)
{
// Paramètres inutilisés
(void)f;
(void)closure;
pthread_t thread;
int err;
// Création d'un thread pour la tâche
if((err = pthread_create(&thread, NULL, (void *(*)(void *))f, closure)) !=
0) {
fprintf(stderr, "pthread_create error %d\n", errno);
if((err = pthread_create(&thread, NULL, sched_worker, &s)) != 0) {
fprintf(stderr, "pthread_create error %d\n", err);
return -1;
}
// Attend la fin du thread
if((err = pthread_join(thread, NULL)) != 0) {
fprintf(stderr, "pthread_join error %d\n", errno);
fprintf(stderr, "pthread_join error %d\n", err);
return -1;
}
return 0;
}
void *
sched_worker(void *arg)
{
(void)arg;
return NULL;
}