View Single Post
  #18   Spotlight this post!  
Unread 06-04-2011, 01:58
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: I Have A Question About Pointers

Quote:
Originally Posted by mikets View Post
In Intel processor architecture, there is the concept of real mode versus protected mode. But there is no such thing in PPC. In PPC, you probably mean kernel mode versus user mode. But that's entirely different thing. For historic reason, Intel processor boots up into real mode where it uses real mode address space seg : offset to form a 20-bit physical address. That will allow you to access only the low 1 Mbyte of memory. PC BIOS runs in this environment and loads the OS loader into memory (Actually much more complicated than that, but this is the simplified view). The OS loader will then set things up and switch the CPU to go into protected mode. The setup includes setting up the virtual memory address tables GDT, LDT and the interrupt table IDT. So once the OS is booted, the CPU is already in protected mode. Everything including both the OS kernel and applications are run in protected mode. However, in protected mode, there are different privileges. Again, for historic reason, Intel processor supports 4 different privileges (rings). But most of the operating systems support only 2 privileges and they are usuually called kernel mode or superviser mode and user mode. Applications are run in user mode and OS kernel, device drivers are usually run in superviser mode.
I am not very familiar with vxWorks but I believe your program is actually compiled as a downloadable kernel module. So I assume it must be running in kernel mode as well which means your program can misbehave and kill the entire system if you are not careful (e.g. run away pointers). BTW, you can do pointer arithmetics in C/C++. There is no need to do that in assembly. But if you are not careful, you can trash memory. For vxWork, you can probably trash kernel mode memory as well and cause a system crash. For Windows application, for example, a run away pointer can only trash application memory. Kernel mode memory is protected from applications. So your application may crash but the OS will be fine. You can just kill the app and move on. However, for Windows kernel mode drivers, they have privilege to access kernel mode memroy. If they have a run away pointer, they could trash kernel mode memory and bring the system down (Blue-Screen aka BugCheck).
Actually it might be in kernel mode. That explains why vXWorks does not have a system call system. You just go do it for yourself, there is no asking for the OS to do it for you.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Reply With Quote