c - Does int 80h interrupt a kernel process? -
first background knowledge, book: linux system programming: talking directly kernel , c library
signals mechanism one-way asynchronous notifications. signal may sent kernel process, process process, or process itself.
the linux kernel implements 30 signals.
signals interrupt executing process, causing stop whatever doing , perform predetermined action.
ok moving further, here quote part:
on intel family of microprocessors, such pentium, int 80h assembly language op code interrupt 80h. syscall interrupt on typical intel-based unix system, such freebsd. allows application programmers obtain system services unix kernel.
i can not quite make connection in head really. when example use
write
method defined in posix, , when compiled assembly, , further assembled object code , linked executable in given architecture runs linux.... system call made right?
i assuming compiled code this:
mov eax,4 ;code system_write mov ebx,1 ;standard output mov ecx, memlocation; memlocation location number of ascii present mov edx, 20; 20 bytes written int 80h;
ok question @ point. int 80h send signal kernel / interrupt kernel? kernel one process? (is init process?) when cpu executes int 80h , happens? registers full of information already, (eax, ebx, ecx , edx in example..), how information used?
i can not quite make connection between cpu - kernel , cpu executes int 80h.
i can imagine code resides somewhere in memory sends required information device driver process code belong to? (i assuming kernel kernel 1 process?) , how int 80h instruction jump code? linux has implement somehow?
is kernel 1 process? (is init process?)
the kernel magic beast. it's not process. kernel doesn't have pid can refer to.
first, it's worth stating (even though it's obvious) instructions runs on processor: therefore, int 80h
executed processor.
there called interrupt request handler
. somehow similar function pointer. processor has table of interrupt handler. table called interrupt descriptor table (aka idt) , system wide (ie, not every process has it's own table). believe table populated kernel when first boot.
so, happens when int 80
executed?
- the processor running in ring 3 protection level (the normal level process). more info on ring level, see this.
- the processor switch ring 0, aka kernel mode. in mode, hardware protection disabled. mean code executed on can whatever wants. write everywhere in physical memory, rewrite interrupt descriptor table, etc.
- the processor jump code located in interrupt descriptor table
80h
interrupt. space available each interruption in idt small. why code jump again somewhere else. - the previous jump lend processor in kernel routine dedicated handling
int 80h
. processor no longer running process' code, running kernel code. - the kernel can check registers , memory , determine why interrupt triggered. understand wanted execute system call
write
. - the kernel code jump again, time in routine handle
write
. kernel runs codewrite
. - the kernel done running code. tells processor go ring 3 protection level, , resume process.
- userspace process (aka process) resumes.
Comments
Post a Comment