none
How to know if code is making "system calls" or "kernel calls" RRS feed

  • Question

  • How to know if code is making "system calls" or "kernel calls"?
    Are system or kernel calls made only during system IO including sockets?? 
    How about initializing variables? creating managing data structures and classes?Do any of these need a trip to OS?

    Tuesday, March 2, 2010 3:10 PM

Answers

  • 1. How to know if code is making "system calls" or "kernel calls"?
    You won't know for sure. That is internal CLR implementation detail. However you can find out by setting breakpoints on some/all system/kernel calls, or you can check out rotor sources, or you can use some advanced profilers which might tell you how many and which system calls were made by application.

    2. Are system or kernel calls made only during system IO including sockets?
    No, there are many other situations when system calls are needed - for example for allocating memory, getting information about processes, etc.

    3. How about initializing variables? Creating managing data structures and classes? Do any of these need a trip to OS?
    It depends: If a class inherits form another type which is in assembly which has not been loaded yet, then you will need some system calls.
    If you need to JIT or load a type, then at least memory allocation is needed from OS calls.
    If you the type is already loaded and object memory is allovated, then initializing object might be just simple zeroing memory or filling memory with values from your constructor.

    If you want to know more about CLR design, you might want to read 'Shared Source CLI Essentials' book.

    -Karel

    Tuesday, March 2, 2010 5:13 PM
    Moderator