Date: Sun, 11 May 1997 08:16:41 -0500 (CDT) From: "Daniel M. Eischen" <deischen@iworks.InterWorks.org> To: freebsd-hackers@FreeBSD.org Subject: GNAT-pthreads integration bugs/questions Message-ID: <199705111316.IAA26518@iworks.InterWorks.org>
next in thread | raw e-mail | index | archive | help
I've implemented Ada tasking in GNAT over FreeBSDs pthreads library. So far everything seems to work great. Thanks to John Birrell for making this possible! I did make some changes to the threads library and have a couple other questions. Problems with pthreads (libc_r:/uthread): o pthreads.h doesn't reflect reality. Where are pthread_setschedparam and pthread_getschedparam? I take it pthread_getprio and pthread_setprio are to be used instead. The same for pthread_attr_setschedparam and pthread_attr_getschedparam, but why is there only pthread_attr_setprio and no pthread_attr_getprio. o Added pthread_attr_getprio (uthread/uthread_attr_getprio.c). o Added uthread_sigwait.c, uthread_attr_getprio.c, and uthread_attr_setprio.c to Makefile.inc in libc_r/uthreads. Questions about layering the GNAT tasking runtime over FreeBSD threads: o There is a mechanism in the GNAT runtime to reserve signals so that they will never allowed to be masked by an application. Like SIGVTALRM because it is used by pthreads (setitimer/getitimer) for scheduling. Pthreads doesn't seem to use SIGALRM, but I've reserved this signal also. Is it safe to allow SIGALRM to be masked? I've also reserved SIGCHLD, SIGSTOP, SIGKILL, and SIGINT. o The Ada language predefines the Constraint_Error and Storage_Error exceptions. A Constraint_Error is raised for things like referencing null pointers, division by zero, going outside the bounds of an array, overflow, etc. A Storage_Error is typically raised when an allocator requires more space than is available for a storage pool. The GNAT runtime provides a signal handler to exception raising mechanism. I've converted SIGFPE and SIGILL to Constraint_Error and SIGSEGV and SIGBUS to Storage_Error. Is there anything in sigcontext that would help to determine which exception should really be raised? Dan Eischen deischen@iworks.InterWorks.org Patches to libc_r/uthread ------8<----------8<----------8<----------8<----------8<---------- *** uthread/Makefile.inc Sat May 10 23:51:49 1997 --- uthread.new/Makefile.inc Sat May 10 21:58:37 1997 *************** *** 9,16 **** --- 11,20 ---- uthread_attr_init.c \ uthread_attr_getdetachstate.c \ + uthread_attr_getprio.c \ uthread_attr_getstackaddr.c \ uthread_attr_getstacksize.c \ uthread_attr_setcreatesuspend_np.c \ uthread_attr_setdetachstate.c \ + uthread_attr_setprio.c \ uthread_attr_setstackaddr.c \ uthread_attr_setstacksize.c \ *************** *** 84,87 **** --- 88,92 ---- uthread_sigsetmask.c \ uthread_sigsuspend.c \ + uthread_sigwait.c \ uthread_socket.c \ uthread_socketpair.c \ *** uthread/uthread_attr_getprio.c Wed Dec 31 19:00:00 1969 --- uthread.new/uthread_attr_getprio.c Sat May 10 21:57:16 1997 *************** *** 0 **** --- 1,49 ---- + /* + * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Birrell. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + #include <errno.h> + #ifdef _THREAD_SAFE + #include <pthread.h> + #include "pthread_private.h" + + int pthread_attr_getprio(pthread_attr_t *attr) + { + int ret; + if (attr == NULL || *attr == NULL) { + errno = EINVAL; + ret = -1; + } else { + ret = (*attr)->prio; + } + return(ret); + } + #endif ------8<----------8<----------8<----------8<----------8<----------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705111316.IAA26518>