diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-02-03 06:24:31 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-02-03 06:24:31 +0100 |
commit | 6a55790197d8eed5b7e020a7b964ae260d0d205b (patch) | |
tree | b416de84487c8bf1ceda846412c9bb29cf80c1fc /sys/src/9/pc/devarch.c | |
parent | c3028fb924d4d112293a885733da60e2e9a730f4 (diff) |
pc/pc64: move common code to pc/devarch.c
Diffstat (limited to 'sys/src/9/pc/devarch.c')
-rw-r--r-- | sys/src/9/pc/devarch.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/sys/src/9/pc/devarch.c b/sys/src/9/pc/devarch.c index 71824f631..4c1ecb691 100644 --- a/sys/src/9/pc/devarch.c +++ b/sys/src/9/pc/devarch.c @@ -1133,3 +1133,62 @@ timerset(Tval x) if(doi8253set) (*arch->timerset)(x); } + +/* + * put the processor in the halt state if we've no processes to run. + * an interrupt will get us going again. + * + * halting in an smp system can result in a startup latency for + * processes that become ready. + * if idle_spin is zero, we care more about saving energy + * than reducing this latency. + * + * the performance loss with idle_spin == 0 seems to be slight + * and it reduces lock contention (thus system time and real time) + * on many-core systems with large values of NPROC. + */ +void +idlehands(void) +{ + extern int nrdy, idle_spin; + + if(conf.nmach == 1) + halt(); + else if(m->cpuidcx & Monitor) + mwait(&nrdy); + else if(idle_spin == 0) + halt(); +} + +int +isaconfig(char *class, int ctlrno, ISAConf *isa) +{ + char cc[32], *p; + int i; + + snprint(cc, sizeof cc, "%s%d", class, ctlrno); + p = getconf(cc); + if(p == nil) + return 0; + + isa->type = ""; + isa->nopt = tokenize(p, isa->opt, NISAOPT); + for(i = 0; i < isa->nopt; i++){ + p = isa->opt[i]; + if(cistrncmp(p, "type=", 5) == 0) + isa->type = p + 5; + else if(cistrncmp(p, "port=", 5) == 0) + isa->port = strtoul(p+5, &p, 0); + else if(cistrncmp(p, "irq=", 4) == 0) + isa->irq = strtoul(p+4, &p, 0); + else if(cistrncmp(p, "dma=", 4) == 0) + isa->dma = strtoul(p+4, &p, 0); + else if(cistrncmp(p, "mem=", 4) == 0) + isa->mem = strtoul(p+4, &p, 0); + else if(cistrncmp(p, "size=", 5) == 0) + isa->size = strtoul(p+5, &p, 0); + else if(cistrncmp(p, "freq=", 5) == 0) + isa->freq = strtoul(p+5, &p, 0); + } + return 1; +} |