When a program is said to be machine dependant - what does this mean?
Can someone give me some examples开发者_JAVA技巧 please?
Using platform specific APIs, ie. Win32 API or Linux API, also if it uses 32 bit or 64 bit specific libraries.
In general: Using any resource that is not present on all machines.
Its where you use a feature that is present say one machine and not another?
Here are some examples:
- Requires certain attachments or ports to be present - say UART modems etc
- Uses instructions that are only present on a particular CPU e.g intel's not amds etc
- Uses an OS feature that may be there in another version of the OS
Essentially the anything that stops the code from running on another machine.
A .NET program may have machine dependencies if it is written using unsafe managed code and/or is dependent upon unmanaged DLLs or platform specific APIs.
"Machine dependent" here usually means dependent upon 32 bit or 64 bit pointer size. Any managed C# code that manipulates IntPtr has a high likelihood of being sensitive to the size of the native machine pointer - 32 bit or 64 bit.
Verifiable managed code is usually machine independent. A .NET application or assembly can be compiled to run in "32 bit or 63 bit" environments, meaning it will JIT compile to native 32 bit or native 64 bit code depending on the OS environment at runtime.
If a managed assembly relies on an unmanaged DLL, this usually means the managed code is tied to the same machine type that the unmanaged DLL is compiled for - either 32 bit or 64 bit, but not both.
"Machine dependent" means that the program behaves differently on one machine that it does on another. Usually, this implies that something about the machine's hardware affects the program. A program might offload certain calculations to the GPU, and thus only work on machines that have a GPU that the program was written to be compatible with. A program might be able to take advantage of some specialty instructions that are particular to one CPU, while on other CPUs it has to emulate that instruction using several.
This is closely related to the idea of "platform dependent", which normally refers to dependencies on a particular operating system or set of system software.
Typically, it means that a program relies upon some property or behavior which exists on one machine but may not exist on others. For example, a particular machine may blink some lights on the cabinet if one invokes an special driver supplied by the cabinet vendor. Code which uses such a driver will only be useful on machines which have that type of cabinet.
精彩评论