diff options
author | julian <julian@FreeBSD.org> | 2004-09-05 02:09:54 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 2004-09-05 02:09:54 +0000 |
commit | 5813d2702971c0732a69541a73be8c44114dd183 (patch) | |
tree | 18da20638d66699090b682ef6c65384dc44ef3e3 /sys/kern/init_main.c | |
parent | 6f864d0a973a7f3987d73132be311b7cfbd1ccfc (diff) | |
download | FreeBSD-src-5813d2702971c0732a69541a73be8c44114dd183.zip FreeBSD-src-5813d2702971c0732a69541a73be8c44114dd183.tar.gz |
Refactor a bunch of scheduler code to give basically the same behaviour
but with slightly cleaned up interfaces.
The KSE structure has become the same as the "per thread scheduler
private data" structure. In order to not make the diffs too great
one is #defined as the other at this time.
The KSE (or td_sched) structure is now allocated per thread and has no
allocation code of its own.
Concurrency for a KSEGRP is now kept track of via a simple pair of counters
rather than using KSE structures as tokens.
Since the KSE structure is different in each scheduler, kern_switch.c
is now included at the end of each scheduler. Nothing outside the
scheduler knows the contents of the KSE (aka td_sched) structure.
The fields in the ksegrp structure that are to do with the scheduler's
queueing mechanisms are now moved to the kg_sched structure.
(per ksegrp scheduler private data structure). In other words how the
scheduler queues and keeps track of threads is no-one's business except
the scheduler's. This should allow people to write experimental
schedulers with completely different internal structuring.
A scheduler call sched_set_concurrency(kg, N) has been added that
notifies teh scheduler that no more than N threads from that ksegrp
should be allowed to be on concurrently scheduled. This is also
used to enforce 'fainess' at this time so that a ksegrp with
10000 threads can not swamp a the run queue and force out a process
with 1 thread, since the current code will not set the concurrency above
NCPU, and both schedulers will not allow more than that many
onto the system run queue at a time. Each scheduler should eventualy develop
their own methods to do this now that they are effectively separated.
Rejig libthr's kernel interface to follow the same code paths as
linkse for scope system threads. This has slightly hurt libthr's performance
but I will work to recover as much of it as I can.
Thread exit code has been cleaned up greatly.
exit and exec code now transitions a process back to
'standard non-threaded mode' before taking the next step.
Reviewed by: scottl, peter
MFC after: 1 week
Diffstat (limited to 'sys/kern/init_main.c')
-rw-r--r-- | sys/kern/init_main.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index cb39a82..6acb6b0 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -90,7 +90,6 @@ static struct session session0; static struct pgrp pgrp0; struct proc proc0; struct thread thread0; -struct kse kse0; struct ksegrp ksegrp0; static struct filedesc0 filedesc0; struct vmspace vmspace0; @@ -320,31 +319,29 @@ proc0_init(void *dummy __unused) register unsigned i; struct thread *td; struct ksegrp *kg; - struct kse *ke; GIANT_REQUIRED; p = &proc0; td = &thread0; - ke = &kse0; kg = &ksegrp0; - ke->ke_sched = kse0_sched; - kg->kg_sched = ksegrp0_sched; - p->p_sched = proc0_sched; - td->td_sched = thread0_sched; - /* * Initialize magic number. */ p->p_magic = P_MAGIC; /* - * Initialize thread, process and pgrp structures. + * Initialize thread, process and ksegrp structures. */ - procinit(); - threadinit(); + procinit(); /* set up proc zone */ + threadinit(); /* set up thead, upcall and KSEGRP zones */ /* + * Initialise scheduler resources. + * Add scheduler specific parts to proc, ksegrp, thread as needed. + */ + schedinit(); /* scheduler gets its house in order */ + /* * Initialize sleep queue hash table */ sleepinit(); @@ -371,13 +368,6 @@ proc0_init(void *dummy __unused) session0.s_leader = p; p->p_sysent = &null_sysvec; - - /* - * proc_linkup was already done in init_i386() or alphainit() etc. - * because the earlier code needed to follow td->td_proc. Otherwise - * I would have done it here.. maybe this means this should be - * done earlier too. - */ p->p_flag = P_SYSTEM; p->p_sflag = PS_INMEM; p->p_state = PRS_NORMAL; @@ -388,10 +378,7 @@ proc0_init(void *dummy __unused) kg->kg_user_pri = PUSER; td->td_priority = PVM; td->td_base_pri = PUSER; - td->td_kse = ke; /* XXXKSE */ td->td_oncpu = 0; - ke->ke_state = KES_THREAD; - ke->ke_thread = td; p->p_peers = 0; p->p_leader = p; |