Changeset 445 for trunk/libs/libpthread


Ignore:
Timestamp:
May 29, 2018, 9:27:23 AM (6 years ago)
Author:
alain
Message:

Restructure the mini_libc.

Location:
trunk/libs/libpthread
Files:
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/libs/libpthread/Makefile

    r444 r445  
    11############################################################################
    2 #                    Makefile for the ALMOS-MKH "mini-pthread"             #
     2#               Makefile for the "pthread" library.                        #
    33############################################################################
    44
    55-include ../../params-soft.mk
     6
    67ifeq ($(ARCH_NAME),)
    78$(error Please define in ARCH_NAME parameter in params-soft.mk!)
     
    910
    1011SRCS = pthread.c
    11 OBJS = $(addprefix build/, $(SRCS:.c=.o))
    12 #       $(HAL_ARCH)/build/core/hal_user.o
    1312
    14 INCLUDES = -I. -I$(HAL)/generic -I$(LIBC_INCLUDE) -I$(LIBALMOSMKH_INCLUDE) -I$(SHARED_INCLUDE)
     13OBJS = $(addprefix build/, $(SRCS:.c=.o)) \
     14       $(HAL_ARCH)/build/core/hal_user.o
    1515
    16 libs : build/lib/libpthread.a headers
     16INCLUDES = -I.                     \
     17           -I$(LIBC_PATH)          \
     18           -I$(LIBALMOSMKH_PATH)   \
     19           -I$(SHARED_INCLUDE)     \
     20           -I$(HAL)/generic        \
     21           -I$(HAL_ARCH)/core      \
     22           -I$(KERNEL)
     23
     24libs : build/lib/libpthread.a  headers
    1725
    1826build :
     
    2432        $(MAKE) -C $(HAL_ARCH)
    2533
    26 ../mini-libc/build/%.o:
    27         $(MAKE) -C ../libc -f Makefile.tsar
    28 
    2934build/%.o : %.c %.h
    3035        $(CC) $(INCLUDES) $(CFLAGS) -c -o  $@ $<
     
    3237
    3338headers: build
    34         cp $(SRCS:.c=.h) build/include/.
     39        cp $(SRCS:.c=.h)  build/include/.
    3540
    3641
    37 build/lib/libpthread.a: build $(OBJS)
    38         $(AR) rc $@ $(OBJS) #$(OBJS_LIBC)
     42build/lib/libpthread.a: build  $(OBJS)
     43        $(AR) rc $@ $(OBJS)
    3944        $(RANLIB) $@
    4045
  • trunk/libs/libpthread/pthread.c

    r444 r445  
    11/*
    2  * pthread.c - User side pthread related functions implementation.
     2 * pthread.c - User leve <pthread> library implementation.
    33 *
    44 * Author     Alain Greiner (2016,2017,2018)
     
    2323
    2424#include <hal_user.h>
     25#include <hal_types.h>
    2526#include <stdio.h>
    2627#include <stdlib.h>
    2728#include <pthread.h>
    28 #include <assert.h>
    29 #include <almos-mkh.h>
     29#include <almosmkh.h>
    3030#include <syscalls_numbers.h>
    3131
    3232#define PTHREAD_MUTEX_DEBUG     0
    3333#define PTHREAD_BARRIER_DEBUG   0
    34 
    35 #define  reg_t     int
    3634
    3735////////////////////////////////////////////////////////////////////////////////////////////
     
    205203
    206204    // check attributes
    207     assert( x_size <= QDT_XMAX );
    208     assert( y_size <= QDT_YMAX );
    209     assert( x_size * y_size * nthreads == count );
     205    if( (x_size * y_size * nthreads) != count )
     206    {
     207        printf("\[ERROR] in %s : count != x_size * y_size * nthreads/n", __FUNCTION__);
     208        exit( EXIT_FAILURE );
     209    }
    210210   
    211211    // compute SQT levels
     
    319319    else                                               // not the last thread
    320320    {
    321         // poll sense
    322321        while( 1 )
    323322        {
     323            // poll sense
    324324            if( node->sense == expected ) break;
     325
     326            // deschedule
     327            pthread_yield();
    325328        }
    326329
  • trunk/libs/libpthread/pthread.h

    r444 r445  
    11/*
    2  * pthread.h - User side pthread related library definition.
     2 * pthread.h - User level <pthread> library definition.
    33 *
    44 * Author     Alain Greiner (2016,2017)
     
    2525#define _PTHREAD_H_
    2626
    27 #include <almos-mkh/pthread.h>
    28 
     27#include <shared_pthread.h>
    2928
    3029//////////////////////////////////////////////////////////////////////////////////////////////
     
    7877int pthread_exit( void * exit_value );
    7978
    80 
    81 
    82 // TODO n'existe pas dans pthread
    8379/*********************************************************************************************
    8480 * This function calls the scheduler for the core running the calling thread.
     81 * WARNING: It is not defined by POSIX.
    8582 *********************************************************************************************
    8683 * @ return always 0.
Note: See TracChangeset for help on using the changeset viewer.