Linux Kernel Architecture

(Jacob Rumans) #1
Mauerer app04.tex V1 - 09/04/2008 6:12pm Page 1230

Appendix D: System Startup


set_trap_gate(16,&coprocessor_error);
set_trap_gate(17,&alignment_check);
set_trap_gate(19,&simd_coprocessor_error);
...
set_system_gate(SYSCALL_VECTOR,&system_call);
...
}

As the code shows, this is also where the interrupt used for system calls is defined as a system
gate (SYSCALL_VECTORis set to0x80).
The IRQ handlers are initialized similarly.
❑ sched_initinitializes the data structures of the scheduler (for the main processor in this case)
and run queues are created.
❑ pidhash_initallocates the hash tables used by the PID allocator to manage free and assigned
PIDs.
❑ softirq_initregisters the softIRQ queues for tasklets with normal and high priority
(TASKLET_SOFTIRQandHI_SOFTIRQ).
❑ time_initreads the system time from the hardware clock. This is a processor-specific function
because different architectures use different mechanisms to read the clock.
❑ init_consoleinitializes the system consoles. Theearly printkmechanism is also disabled on
systems that provide this facility to allow messages to be output to the console before it has been
fully initialized (on other systems, messages are buffered until the console is activated).
❑ page_address_initsets up the hash table that the Persistent Kernel Map (PKMap) mechanism
uses to determine the physical page address of a permanent kernel mapping by reference to a
given virtual address.
❑ mem_initdisables the bootmem allocator (and performs a number of minor architecture-specific
actions that are of no concern), andkmem_cache_initinitializes the slab allocator in a multistage
process described in detail in Chapter 3.
❑ calibrate_delaycalculates the BogoMIPS value, which specifies how many empty loops the
CPU can run through per jiffy. The kernel requires this value to estimate the time needed for
some tasks that are performed with polling or busy waiting. The following code yields a good
approximation of the number of loops per jiffy and stores the result inloops_per_jiffy^2 :
init/calibrate.c
void __init calibrate_delay(void)
{
unsigned long ticks, loopbit;
int lps_precision = LPS_PREC;

loops_per_jiffy = (1<<12);

printk("Calibrating delay loop... ");
while (loops_per_jiffy <<= 1) {
/* wait for "start of" clock tick */

(^2) It is also possible to preset the BogoMIPS value, but this prevents the kernel from doing one of the most important operations ever,
which would clearly be boring.

Free download pdf