ATA DISK TO MUCH FASTER UNDER QEMU

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
giumaug
Posts: 1
Joined: Wed Jan 15, 2014 3:50 am

ATA DISK TO MUCH FASTER UNDER QEMU

Post by giumaug »

HI,
just for fun i'm writing a little kernel.
I have implemented some stuff such scheduler,memory manager syscall and other.
Usually i use bochs or quemu and gdb to debug.
At the moment i'm writing ata driver.
I noted a strange behavior under bochs and qemu.
When try to write a sector bochs fire interrupt just after write command.
In real system storage latency is in the milliseconds order.
So my question is:
Bochs/Qemu reflects real hardware ata latency?
Below a snippet code of my driver:

67:out(0xE0 | (io_request->lba >> 24),0x1F6);
68:out((unsigned char)io_request->sector_count,0x1F2);
69 out((unsigned char)io_request->lba,0x1F3);
70 out((unsigned char)(io_request->lba >> 8),0x1F4);
71 out((unsigned char)(io_request->lba >> 16),0x1F5);
72 out(io_request->command,0x1F7);

After instruction at line 72 (write command) i receive an interrupt and code jump to int handler:

disable_irq_line(14);
system.int_path_count++;
EOI_TO_SLAVE_PIC
EOI_TO_MASTER_PIC

if (system.device_desc->serving_request->process_context!=NULL)
{
_awake(system.device_desc->serving_request->process_context);
}
system.device_desc->status=DEVICE_IDLE;
enable_irq_line(14);

In this scenario handler try to awake a not sleeping process!!!!
I verified the interrupt refer to previuos command infact disk sector appear written correctly.
Can someone help?

Best Regards
Giuseppe.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: ATA DISK TO MUCH FASTER UNDER QEMU

Post by iansjack »

I think it's a little unrealistic to expect virtual machines to replicate the seek times of real mechanical disks. Try attaching a real disk to the virtual machine instead of a virtual one and see if you get the same results. Or test the latency of real hardware with an SSD rather than a mechanical hard disk.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: ATA DISK TO MUCH FASTER UNDER QEMU

Post by Owen »

Your design obviously contains a race condition that QEMU is helpfully highlighting for you
Post Reply