1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Add kse_switchin(2). This syscall can be used by KSE implementations

to have the kernel switch to a new thread, instead of doing it in
userland. It is in fact needed on ia64 where syscall restarts do not
return to userland first. It's completely handled inside the kernel.
As such, any context created by the kernel as part of an upcall and
caused by some syscall needs to be restored by the kernel.
This commit is contained in:
Marcel Moolenaar 2003-12-07 19:34:29 +00:00
parent c51633823d
commit 702b2a179c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=123252
4 changed files with 51 additions and 0 deletions

View File

@ -382,6 +382,30 @@ proc_linkup(struct proc *p, struct ksegrp *kg,
thread_link(td, kg);
}
#ifndef _SYS_SYSPROTO_H_
struct kse_switchin_args {
const struct __mcontext *mcp;
long val;
long *loc;
};
#endif
int
kse_switchin(struct thread *td, struct kse_switchin_args *uap)
{
mcontext_t mc;
int error;
error = (uap->mcp == NULL) ? EINVAL : 0;
if (!error)
error = copyin(uap->mcp, &mc, sizeof(mc));
if (!error)
error = set_mcontext(td, &mc);
if (!error && uap->loc != NULL)
suword(uap->loc, uap->val);
return ((error == 0) ? EJUSTRETURN : error);
}
/*
struct kse_thr_interrupt_args {
struct kse_thr_mailbox * tmbx;

View File

@ -382,6 +382,30 @@ proc_linkup(struct proc *p, struct ksegrp *kg,
thread_link(td, kg);
}
#ifndef _SYS_SYSPROTO_H_
struct kse_switchin_args {
const struct __mcontext *mcp;
long val;
long *loc;
};
#endif
int
kse_switchin(struct thread *td, struct kse_switchin_args *uap)
{
mcontext_t mc;
int error;
error = (uap->mcp == NULL) ? EINVAL : 0;
if (!error)
error = copyin(uap->mcp, &mc, sizeof(mc));
if (!error)
error = set_mcontext(td, &mc);
if (!error && uap->loc != NULL)
suword(uap->loc, uap->val);
return ((error == 0) ? EJUSTRETURN : error);
}
/*
struct kse_thr_interrupt_args {
struct kse_thr_mailbox * tmbx;

View File

@ -639,6 +639,8 @@
int attrnamespace, void *data, size_t nbytes); }
439 STD BSD { ssize_t extattr_list_link(const char *path, \
int attrnamespace, void *data, size_t nbytes); }
440 MSTD BSD { int kse_switchin(const struct __mcontext *mcp, \
long val, long *loc); }
; Please copy any additions and changes to the following compatability tables:
; sys/ia64/ia32/syscalls.master (take a best guess)

View File

@ -109,6 +109,7 @@ int kse_exit(void);
int kse_release(struct timespec *);
int kse_thr_interrupt(struct kse_thr_mailbox *, int, long);
int kse_wakeup(struct kse_mailbox *);
int kse_switchin(mcontext_t *, long, long *);
#endif /* !_KERNEL */
#endif /* !_SYS_KSE_H_ */