Skip to content
Extraits de code Groupes Projets
fonctions.h 1,08 ko
Newer Older
  • Learn to ignore specific revisions
  • Arnaud Lefebvre's avatar
    Arnaud Lefebvre a validé
    #ifndef fonctions_h
    #define fonctions_h
    
    typedef struct node {
    
    Arnaud Lefebvre's avatar
    Arnaud Lefebvre a validé
        uint64_t value;
    
    Arnaud Lefebvre's avatar
    Arnaud Lefebvre a validé
        struct node *next;
    } node_t;
    
    typedef struct list {
        node_t *first;
        node_t *last;
        int length;
    } list_t;
    
    typedef struct node2 {
        list_t *diviseurs;
        struct node2 *next;
    } node_lst;
    
    typedef struct list2 {
        node_lst *first;
        node_lst *last;
        int length;
    } list_lst;
    
    typedef struct buffer1 {
        list_t *numbers;
        sem_t free;
        sem_t full;
        pthread_mutex_t mutex;
        bool can_stop;
    } buffer1;
    
    typedef struct buffer2 {
        list_lst *prime_numbers;
        sem_t free;
        sem_t full;
        pthread_mutex_t mutex;
    } buffer2;
    
    void init_list_t(list_t *my_list);
    void init_list_lst(list_lst *my_list);
    
    Arnaud Lefebvre's avatar
    Arnaud Lefebvre a validé
    void put_node_t(list_t *my_list, uint64_t value);
    
    Arnaud Lefebvre's avatar
    Arnaud Lefebvre a validé
    void put_node_lst(list_lst *my_list, list_t *put_list);
    
    Arnaud Lefebvre's avatar
    Arnaud Lefebvre a validé
    uint64_t get_node_t(list_t *my_list);
    
    Arnaud Lefebvre's avatar
    Arnaud Lefebvre a validé
    list_t *get_node_lst(list_lst *my_list);
    
    void clear_list_t(list_t *my_list);
    
    
    Arnaud Lefebvre's avatar
    Arnaud Lefebvre a validé
    list_t *prime_list(uint64_t value);
    
    Arnaud Lefebvre's avatar
    Arnaud Lefebvre a validé
    
    
    Arnaud Lefebvre's avatar
    Arnaud Lefebvre a validé
    int count_lines(char *filename);
    
    
    Arnaud Lefebvre's avatar
    Arnaud Lefebvre a validé
    buffer1 *init_buffer_1(int nthreads);
    buffer2 *init_buffer_2(int nthreads);
    
    #endif //fonctions_h