void print_k(struct bstnode *node,int k,int h)
{
	int temp;
	if (node == NULL) {
		return;
	}
	print_k(node -> left,k,h);
	temp = height(node);
	printf("%d\n",temp);
	if (temp == h - k) {
		printf("%d ",node -> data);
	}
	print_k(node -> right,k,h);
}
Example #2
0
int hello_init(void)
{
	printk("init_module\n");
	printk("global_data = %d\n",global_data);
	print_k();
	return 0;
}
int main()
{
	int v, n, i, k, h;
	struct bstnode* root;
	root = NULL;
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%d", &v);
		root = insert(root,v);
	}
	scanf("%d", &k);
	h = height(root);
	print_k(root,k,h);
	return 0;
}
Example #4
0
/* All of our Exception handling Interrupt Service Routines will
*  point to this function. This will tell us what exception has
*  happened! Right now, we simply halt the system by hitting an
*  endless loop. All ISRs disable interrupts while they are being
*  serviced as a 'locking' mechanism to prevent an IRQ from
*  happening and messing up kernel data structures */
void fault_handler(struct regs *r)
{
    /* Is this a fault whose number is from 0 to 31? */
    if (r->int_no < 32)
    {
        /* Display the description for the Exception that occurred.
        *  In this tutorial, we will simply halt the system using an
        *  infinite loop */
       // write(exception_messages[r->int_no],-1);
        //write(" Exception. System Halted!\n",-1);
        char *exception_message = exception_messages[r->int_no];

        print_k("The following Exception Occured: %s and its ID is %d\n",exception_message,r->int_no);
        //
        panic(exception_message);
    }
}
Example #5
0
/* Installs the IDT */
void idt_install()
{
    /* Sets the special IDT pointer up, just like in 'gdt.c' */
	idtp.limit = (sizeof (struct idt_entry) * 256) - 1;
	idtp.base =  (unsigned int)&idt;

	memset((unsigned char *)&idt,0,sizeof(struct idt_entry)*256);
	/* Add any new ISRs to the IDT here using idt_set_gate */

	irq_remap();

	isrs_install();
	irq_install();

	idt_load();
	/* Points the processor's internal register to the new IDT */
	print_k("%s\n",IDT_MESSAGE);
}
Example #6
0
void isrs_install()
{
	idt_set_gate(0, (unsigned)interrupt_handler_0, 0x08, 0x8E);
	idt_set_gate(1, (unsigned)interrupt_handler_1, 0x08, 0x8E);
	idt_set_gate(2, (unsigned)interrupt_handler_2, 0x08, 0x8E);
	idt_set_gate(3, (unsigned)interrupt_handler_3, 0x08, 0x8E);
	idt_set_gate(4, (unsigned)interrupt_handler_4, 0x08, 0x8E);
	idt_set_gate(5, (unsigned)interrupt_handler_5, 0x08, 0x8E);
	idt_set_gate(6, (unsigned)interrupt_handler_6, 0x08, 0x8E);
	idt_set_gate(7, (unsigned)interrupt_handler_7, 0x08, 0x8E);
	idt_set_gate(8, (unsigned)interrupt_handler_8, 0x08, 0x8E);
	idt_set_gate(9, (unsigned)interrupt_handler_9, 0x08, 0x8E);
	idt_set_gate(10, (unsigned)interrupt_handler_10, 0x08, 0x8E);
	idt_set_gate(11, (unsigned)interrupt_handler_11, 0x08, 0x8E);
	idt_set_gate(12, (unsigned)interrupt_handler_12, 0x08, 0x8E);
	idt_set_gate(13, (unsigned)interrupt_handler_13, 0x08, 0x8E);
	idt_set_gate(14, (unsigned)interrupt_handler_14, 0x08, 0x8E);
	idt_set_gate(15, (unsigned)interrupt_handler_15, 0x08, 0x8E);
	idt_set_gate(16, (unsigned)interrupt_handler_16, 0x08, 0x8E);
	idt_set_gate(17, (unsigned)interrupt_handler_17, 0x08, 0x8E);
	idt_set_gate(18, (unsigned)interrupt_handler_18, 0x08, 0x8E);
	idt_set_gate(19, (unsigned)interrupt_handler_19, 0x08, 0x8E);
	idt_set_gate(20, (unsigned)interrupt_handler_20, 0x08, 0x8E);
	idt_set_gate(21, (unsigned)interrupt_handler_21, 0x08, 0x8E);
	idt_set_gate(22, (unsigned)interrupt_handler_22, 0x08, 0x8E);
	idt_set_gate(23, (unsigned)interrupt_handler_23, 0x08, 0x8E);
	idt_set_gate(24, (unsigned)interrupt_handler_24, 0x08, 0x8E);
	idt_set_gate(25, (unsigned)interrupt_handler_25, 0x08, 0x8E);
	idt_set_gate(26, (unsigned)interrupt_handler_26, 0x08, 0x8E);
	idt_set_gate(27, (unsigned)interrupt_handler_27, 0x08, 0x8E);
	idt_set_gate(28, (unsigned)interrupt_handler_28, 0x08, 0x8E);
	idt_set_gate(29, (unsigned)interrupt_handler_29, 0x08, 0x8E);
	idt_set_gate(30, (unsigned)interrupt_handler_30, 0x08, 0x8E);
	idt_set_gate(31, (unsigned)interrupt_handler_31, 0x08, 0x8E);

	print_k("%s\n",ISR_MESSAGE);
}