1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-13 10:02:38 +00:00

Modifications to existing files to support the initial AIO/LIO and

kernel based threading support.
This commit is contained in:
John Dyson 1997-06-16 00:29:36 +00:00
parent ee877a356c
commit 2c1011f7ef
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=26671
14 changed files with 193 additions and 9 deletions

View File

@ -119,6 +119,8 @@ kern/vfs_lookup.c standard
kern/vfs_subr.c standard
kern/vfs_syscalls.c standard
kern/vfs_vnops.c standard
kern/kern_threads.c standard
kern/vfs_aio.c standard
miscfs/deadfs/dead_vnops.c standard
miscfs/devfs/devfs_tree.c optional devfs
miscfs/devfs/devfs_vfsops.c optional devfs

View File

@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* @(#)init_main.c 8.9 (Berkeley) 1/21/94
* $Id: init_main.c,v 1.62 1997/05/11 18:05:36 tegge Exp $
* $Id: init_main.c,v 1.63 1997/05/29 04:52:03 peter Exp $
*/
#include "opt_rlimit.h"
@ -339,6 +339,12 @@ proc0_init(dummy)
p->p_rtprio.type = RTP_PRIO_NORMAL;
p->p_rtprio.prio = 0;
/*
* Link for kernel based threads
*/
p->p_peers = 0;
p->p_leader = p;
bcopy("swapper", p->p_comm, sizeof ("swapper"));
/* Create credentials. */

View File

@ -346,4 +346,16 @@ struct sysent sysent[] = {
{ 0, (sy_call_t *)nosys }, /* 311 = setresuid */
{ 0, (sy_call_t *)nosys }, /* 312 = setresgid */
{ 3, (sy_call_t *)signanosleep }, /* 313 = signanosleep */
{ 1, (sy_call_t *)aio_return }, /* 314 = aio_return */
{ 3, (sy_call_t *)aio_suspend }, /* 315 = aio_suspend */
{ 2, (sy_call_t *)aio_cancel }, /* 316 = aio_cancel */
{ 1, (sy_call_t *)aio_error }, /* 317 = aio_error */
{ 1, (sy_call_t *)aio_read }, /* 318 = aio_read */
{ 1, (sy_call_t *)aio_write }, /* 319 = aio_write */
{ 4, (sy_call_t *)lio_listio }, /* 320 = lio_listio */
{ 0, (sy_call_t *)yield }, /* 321 = yield */
{ 1, (sy_call_t *)thr_sleep }, /* 322 = thr_sleep */
{ 1, (sy_call_t *)thr_wakeup }, /* 323 = thr_wakeup */
{ 1, (sy_call_t *)mlockall }, /* 324 = mlockall */
{ 0, (sy_call_t *)munlockall }, /* 325 = munlockall */
};

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
* $Id: kern_exit.c,v 1.47 1997/04/07 07:16:00 peter Exp $
* $Id: kern_exit.c,v 1.48 1997/05/22 07:25:20 phk Exp $
*/
#include "opt_ktrace.h"
@ -125,6 +125,37 @@ exit1(p, rv)
WTERMSIG(rv), WEXITSTATUS(rv));
panic("Going nowhere without my init!");
}
/* are we a task leader? */
if(p == p->p_leader) {
struct kill_args killArgs;
killArgs.signum = SIGKILL;
q = p->p_peers;
while(q) {
killArgs.pid = q->p_pid;
/*
* The interface for kill is better
* than the internal signal
*/
kill(p, &killArgs, &rv);
nq = q;
q = q->p_peers;
/*
* orphan the threads so we don't mess up
* when they call exit
*/
nq->p_peers = 0;
nq->p_leader = nq;
}
/* otherwise are we a peer? */
} else if(p->p_peers) {
q = p->p_leader;
while(q->p_peers != p)
q = q->p_peers;
q->p_peers = p->p_peers;
}
#ifdef PGINPROF
vmsizmon();
#endif

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_fork.c 8.6 (Berkeley) 4/8/94
* $Id: kern_fork.c,v 1.41 1997/04/26 15:59:50 peter Exp $
* $Id: kern_fork.c,v 1.42 1997/05/29 04:52:04 peter Exp $
*/
#include "opt_ktrace.h"
@ -218,6 +218,20 @@ fork1(p1, flags, retval)
/* Allocate new proc. */
MALLOC(newproc, struct proc *, sizeof(struct proc), M_PROC, M_WAITOK);
/*
* Setup linkage for kernel based threading
*/
if((flags & RFTHREAD) != 0) {
newproc->p_peers = p1->p_peers;
p1->p_peers = newproc;
newproc->p_leader = p1->p_leader;
} else {
newproc->p_peers = 0;
newproc->p_leader = newproc;
}
newproc->p_wakeup = 0;
/*
* Find an unused process ID. We remember a range of unused IDs
* ready to use (from nextpid+1 through pidchecked-1).

View File

@ -1,6 +1,6 @@
#! /bin/sh -
# @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93
# $Id: makesyscalls.sh,v 1.21 1997/02/22 09:39:14 peter Exp $
# $Id: makesyscalls.sh,v 1.22 1997/03/29 11:11:18 peter Exp $
set -e
@ -105,6 +105,7 @@ s/\$//g
printf " * created from%s\n */\n\n", $0 > sysarg
printf("#ifndef %s\n", sysproto_h) > sysarg
printf("#define\t%s\n\n", sysproto_h) > sysarg
printf "#include <sys/aio.h>\n" > sysarg
printf "#include <sys/signal.h>\n\n", $0 > sysarg
printf " * created from%s\n */\n\n", $0 > sysnames

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)sys_generic.c 8.5 (Berkeley) 1/21/94
* $Id: sys_generic.c,v 1.25 1997/03/23 03:36:23 bde Exp $
* $Id: sys_generic.c,v 1.26 1997/03/24 11:52:25 bde Exp $
*/
#include "opt_ktrace.h"
@ -99,6 +99,7 @@ read(p, uap, retval)
aiov.iov_len = uap->nbyte;
auio.uio_iov = &aiov;
auio.uio_iovcnt = 1;
auio.uio_offset = -1;
auio.uio_resid = uap->nbyte;
if (auio.uio_resid < 0)
@ -176,6 +177,7 @@ readv(p, uap, retval)
auio.uio_rw = UIO_READ;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_procp = p;
auio.uio_offset = -1;
if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen)))
goto done;
auio.uio_resid = 0;
@ -250,6 +252,7 @@ write(p, uap, retval)
aiov.iov_len = uap->nbyte;
auio.uio_iov = &aiov;
auio.uio_iovcnt = 1;
auio.uio_offset = -1;
auio.uio_resid = uap->nbyte;
auio.uio_rw = UIO_WRITE;
auio.uio_segflg = UIO_USERSPACE;
@ -327,6 +330,7 @@ writev(p, uap, retval)
auio.uio_rw = UIO_WRITE;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_procp = p;
auio.uio_offset = -1;
if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen)))
goto done;
auio.uio_resid = 0;

View File

@ -335,4 +335,16 @@ char *syscallnames[] = {
"#311", /* 311 = setresuid */
"#312", /* 312 = setresgid */
"signanosleep", /* 313 = signanosleep */
"aio_return", /* 314 = aio_return */
"aio_suspend", /* 315 = aio_suspend */
"aio_cancel", /* 316 = aio_cancel */
"aio_error", /* 317 = aio_error */
"aio_read", /* 318 = aio_read */
"aio_write", /* 319 = aio_write */
"lio_listio", /* 320 = lio_listio */
"yield", /* 321 = yield */
"thr_sleep", /* 322 = thr_sleep */
"thr_wakeup", /* 323 = thr_wakeup */
"mlockall", /* 324 = mlockall */
"munlockall", /* 325 = munlockall */
};

View File

@ -1,4 +1,4 @@
$Id: syscalls.master,v 1.38 1997/05/08 14:07:11 peter Exp $
$Id: syscalls.master,v 1.39 1997/06/01 08:52:38 peter Exp $
; from: @(#)syscalls.master 8.2 (Berkeley) 1/13/94
;
; System call name/number master file.
@ -462,3 +462,15 @@
312 UNIMPL NOHIDE setresgid
313 STD BSD { int signanosleep(const struct timespec *rqtp, \
struct timespec *rmtp, sigset_t *mask); }
314 STD BSD { int aio_return(struct aiocb *aiocbp); }
315 STD BSD { int aio_suspend(struct aiocb * const * aiocbp, int nent, const struct timespec *timeout); }
316 STD BSD { int aio_cancel(int fd, struct aiocb *aiocbp); }
317 STD BSD { int aio_error(struct aiocb *aiocbp); }
318 STD BSD { int aio_read(struct aiocb *aiocbp); }
319 STD BSD { int aio_write(struct aiocb *aiocbp); }
320 STD BSD { int lio_listio(int mode, struct aiocb * const *acb_list, int nent, struct sigevent *sig); }
321 STD BSD { int yield(void); }
322 STD BSD { int thr_sleep(const struct timespec *timeout); }
323 STD BSD { int thr_wakeup(pid_t pid); }
324 STD BSD { int mlockall(int how); }
325 STD BSD { int munlockall(void); }

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)proc.h 8.15 (Berkeley) 5/19/95
* $Id: proc.h,v 1.38 1997/05/22 07:24:46 phk Exp $
* $Id: proc.h,v 1.39 1997/06/01 08:49:49 peter Exp $
*/
#ifndef _SYS_PROC_H_
@ -178,6 +178,12 @@ struct proc {
u_short p_xstat; /* Exit status for wait; also stop signal. */
u_short p_acflag; /* Accounting flags. */
struct rusage *p_ru; /* Exit information. XXX */
int p_nthreads; /* number of threads (only in leader) */
int p_npeers; /* number of kernel threads (only in leader) */
int p_wakeup; /* thread id */
struct proc *p_peers;
struct proc *p_leader;
};
#define p_session p_pgrp->pg_session
@ -218,6 +224,9 @@ struct proc {
#define P_SWAPINREQ 0x80000 /* Swapin request due to wakeup */
#define P_IDLEPROC 0x100000 /* Process is an idle-eater, don't count */
/* Marked a kernel thread */
#define P_KTHREADP 0x200000 /* Process is really a kernel thread */
/*
* MOVE TO ucred.h?
*

View File

@ -229,3 +229,15 @@ HIDE_BSD(kldnext)
HIDE_BSD(kldstat)
HIDE_BSD(kldfirstmod)
HIDE_BSD(signanosleep)
HIDE_BSD(aio_return)
HIDE_BSD(aio_suspend)
HIDE_BSD(aio_cancel)
HIDE_BSD(aio_error)
HIDE_BSD(aio_read)
HIDE_BSD(aio_write)
HIDE_BSD(lio_listio)
HIDE_BSD(yield)
HIDE_BSD(thr_sleep)
HIDE_BSD(thr_wakeup)
HIDE_BSD(mlockall)
HIDE_BSD(munlockall)

View File

@ -223,4 +223,16 @@
#define SYS_kldstat 308
#define SYS_kldfirstmod 309
#define SYS_signanosleep 313
#define SYS_MAXSYSCALL 314
#define SYS_aio_return 314
#define SYS_aio_suspend 315
#define SYS_aio_cancel 316
#define SYS_aio_error 317
#define SYS_aio_read 318
#define SYS_aio_write 319
#define SYS_lio_listio 320
#define SYS_yield 321
#define SYS_thr_sleep 322
#define SYS_thr_wakeup 323
#define SYS_mlockall 324
#define SYS_munlockall 325
#define SYS_MAXSYSCALL 326

View File

@ -8,6 +8,7 @@
#ifndef _SYS_SYSPROTO_H_
#define _SYS_SYSPROTO_H_
#include <sys/aio.h>
#include <sys/signal.h>
struct nosys_args {
@ -786,6 +787,48 @@ struct signanosleep_args {
struct timespec * rmtp;
sigset_t * mask;
};
struct aio_return_args {
struct aiocb * aiocbp;
};
struct aio_suspend_args {
struct aiocb *const * aiocbp;
int nent;
const struct timespec * timeout;
};
struct aio_cancel_args {
int fd;
struct aiocb * aiocbp;
};
struct aio_error_args {
struct aiocb * aiocbp;
};
struct aio_read_args {
struct aiocb * aiocbp;
};
struct aio_write_args {
struct aiocb * aiocbp;
};
struct lio_listio_args {
int mode;
struct aiocb *const * acb_list;
int nent;
struct sigevent * sig;
};
struct yield_args {
int dummy;
};
struct thr_sleep_args {
const struct timespec * timeout;
};
struct thr_wakeup_args {
pid_t pid;
};
struct mlockall_args {
int how;
};
struct munlockall_args {
int dummy;
};
int nosys __P((struct proc *, struct nosys_args *, int []));
void exit __P((struct proc *, struct rexit_args *, int [])) __dead2;
int fork __P((struct proc *, struct fork_args *, int []));
@ -973,6 +1016,18 @@ int kldnext __P((struct proc *, struct kldnext_args *, int []));
int kldstat __P((struct proc *, struct kldstat_args *, int []));
int kldfirstmod __P((struct proc *, struct kldfirstmod_args *, int []));
int signanosleep __P((struct proc *, struct signanosleep_args *, int []));
int aio_return __P((struct proc *, struct aio_return_args *, int []));
int aio_suspend __P((struct proc *, struct aio_suspend_args *, int []));
int aio_cancel __P((struct proc *, struct aio_cancel_args *, int []));
int aio_error __P((struct proc *, struct aio_error_args *, int []));
int aio_read __P((struct proc *, struct aio_read_args *, int []));
int aio_write __P((struct proc *, struct aio_write_args *, int []));
int lio_listio __P((struct proc *, struct lio_listio_args *, int []));
int yield __P((struct proc *, struct yield_args *, int []));
int thr_sleep __P((struct proc *, struct thr_sleep_args *, int []));
int thr_wakeup __P((struct proc *, struct thr_wakeup_args *, int []));
int mlockall __P((struct proc *, struct mlockall_args *, int []));
int munlockall __P((struct proc *, struct munlockall_args *, int []));
#ifdef COMPAT_43

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)unistd.h 8.2 (Berkeley) 1/7/94
* $Id$
* $Id: unistd.h,v 1.13 1997/02/22 09:46:21 peter Exp $
*/
#ifndef _SYS_UNISTD_H_
@ -138,7 +138,9 @@
#define RFCNAMEG (1<<10) /* UNIMPL zero plan9 `name space' */
#define RFCENVG (1<<11) /* UNIMPL zero plan9 `env space' */
#define RFCFDG (1<<12) /* zero fd table */
#define RFTHREAD (1<<13) /* enable kernel thread support */
#define RFPPWAIT (1<<31) /* parent sleeps until child exits (vfork) */
#endif /* !_POSIX_SOURCE */
#endif /* !_SYS_UNISTD_H_ */