Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jun 2002 03:42:45 -0700 (PDT)
From:      Julian Elischer <julian@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 12911 for review
Message-ID:  <200206141042.g5EAgj035717@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=12911

Change 12911 by julian@julian_jules1 on 2002/06/14 03:42:10

	Start changing the API a bit.

Affected files ...

... //depot/projects/kse/sys/i386/i386/vm_machdep.c#48 edit
... //depot/projects/kse/sys/kern/kern_proc.c#66 edit
... //depot/projects/kse/sys/sys/kse.h#9 edit
... //depot/projects/kse/sys/sys/proc.h#108 edit

Differences ...

==== //depot/projects/kse/sys/i386/i386/vm_machdep.c#48 (text+ko) ====

@@ -309,6 +309,7 @@
 void
 cpu_save_upcall(struct thread *td, struct kse *newkse)
 {
+	struct trapframe *tf
 
 	newkse->ke_mdstorage = malloc(sizeof(struct md_store), M_TEMP,
 	    M_WAITOK);
@@ -318,13 +319,21 @@
 	    &(((struct md_store *)(newkse->ke_mdstorage))->mds_pcb);
 	newkse->ke_frame =
 	    &(((struct md_store *)(newkse->ke_mdstorage))->mds_frame);
+	tf = newkse->ke_frame
 
 	/* Copy the upcall pcb. Kernel mode & fp regs are here. */
 	/* XXXKSE this may be un-needed */
 	bcopy(td->td_pcb, newkse->ke_pcb, sizeof(struct pcb));
 
 	/* This copies most of the user mode register values. */
-	bcopy(td->td_frame, newkse->ke_frame, sizeof(struct trapframe));
+	bzero(newkse->ke_frame, sizeof(struct trapframe));
+	tf->tf_edi = 0;
+	tf->tf_esi = 0;		    /* trampoline arg */
+	tf->tf_ebp = 0;
+	tf->tf_esp = (int) newkse->ke_stackbase + newkse->ke_stacksize - 16;
+	tf->tf_ebx = 0;		    /* trampoline arg */
+	tf->tf_eip = (int)newkse->ke_upcall;
+	/*
 }
 
 void

==== //depot/projects/kse/sys/kern/kern_proc.c#66 (text+ko) ====

@@ -201,6 +201,10 @@
 }
 
 
+/* 
+ * No new KSEG: first call: use current KSE, don't schedule an upcall
+ * All other situations, do alloate a new KSE and schedule an upcall on it.
+ */
 /* struct kse_new_args {
 	struct kse_mailbox *mbx;
 	int	new_grp_flag;
@@ -210,8 +214,12 @@
 {
 	struct kse *newkse;
 	struct proc *p;
+	struct kse_mailbox mbx;
+	int err;
 
 	p = td->td_proc;
+	if ((err = copyin(uap->mbx, &mbx, sizeof(mbx))))
+		return (err);
 	PROC_LOCK(p);
 	/*
 	 * If we have no KSE mode set, just set it, and skip KSE and KSEGRP
@@ -219,7 +227,7 @@
 	 * you are effectively getting one. Instead, go directly to saving
 	 * the upcall info.
 	 */
-	if (td->td_proc->p_flag & P_KSES) {
+	if ((td->td_proc->p_flag & P_KSES) || (uap->new_grp_flag)) {
 
 		return (EINVAL);	/* XXX */
 		/*
@@ -246,20 +254,23 @@
 	mi_switch();	/* Save current registers to PCB. */
 	mtx_unlock_spin(&sched_lock);
 	PROC_LOCK(p);
+	newkse->ke_upcall = mbx.kmbx_upcall;
+	newkse->ke_stackbase  = mbx.kmbx_stackbase;
+	newkse->ke_stacksize = mbx.kmbx_stacksize;
+	newkse->ke_mailbox = uap->mbx;
 	cpu_save_upcall(td, newkse);
-	newkse->ke_mailbox = uap->mbx;
 	PROC_UNLOCK(p);
 	/* Note that we are the returning syscall */
 	td->td_retval[0] = 1;
 	td->td_retval[1] = 0;
 
-	if (td->td_proc->p_flag & P_KSES) {
+	if ((td->td_proc->p_flag & P_KSES) || (uap->new_grp_flag)) {
 		thread_schedule_upcall(td, newkse);
 	} else {
 		/*
-		 * Don't set this untill we are truely ready, because
+		 * Don't set this until we are truely ready, because
 		 * things will start acting differently.  Return to the
-		 * upcall code for the first time.  Assuming we set up
+		 * calling code for the first time.  Assuming we set up
 		 * the mailboxes right, all syscalls after this will be
 		 * asynchronous.
 		 */

==== //depot/projects/kse/sys/sys/kse.h#9 (text+ko) ====

@@ -38,7 +38,8 @@
  * the userland and the kernel when running a KSE-based threading system.
  * The only programs that should see this file are the UTS and the kernel.
  */
-
+struct kse_mailbox;
+typedef void kse_fn_t(struct kse_mailbox *mbx)
 /* 
  * Each userland thread has one of these buried in it's 
  * Thread control structure somewhere.
@@ -58,10 +59,13 @@
  */
 struct kse_mailbox 
 {
-	struct thread_mailbox *current_thread;
-	struct thread_mailbox *completed_threads;
-	unsigned int	flags;
-	void		*UTS_handle;	/* The UTS can use this for anything */
+	kse_fn_t	*kmbx_upcall;
+	caddr_t		kmbx_stackbase;
+	unsigned long int kmbx_stacksize;
+	struct thread_mailbox *kmbx_current_thread;
+	struct thread_mailbox *kmbx_completed_threads;
+	unsigned int	kmbx_flags;
+	void		*kmbx_UTS_handle; /* UTS can use this for anything */
 };
 #define KEMBXF_CRITICAL 0x00000001
 

==== //depot/projects/kse/sys/sys/proc.h#108 (text+ko) ====

@@ -368,6 +368,9 @@
 	u_char		ke_dummy;	/*   */
 #define	ke_endcopy ke_mdstorage
 
+	void		*ke_upcall;
+	void		*ke_stackbase;
+	u_long		*ke_stacksize;
 	void 		*ke_mdstorage;	/* where we store the pcb and frame */
 	struct pcb	*ke_pcb;	/* the pcb saved for the upcalls */
 	struct trapframe *ke_frame;	/* the upcall trapframe */

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206141042.g5EAgj035717>