Thursday, March 31, 2005

Scott Hanselman posted some of the .Net interview questions on his blog, dividing it into several segments. I tried to answer them in parts, in little elaborated way, by putting definitions with answers. You really can’t get away with Google to do it all. I took reference from some websites to elaborate the definition. Here goes part I of the series…

Everyone who writes code…

  • Describe the difference between a Thread and a Process?

Process:  A process is a single executable module (.Exe file) that runs concurrently with other executable modules. For example, an internet browser and a word processor can run simultaneously. Processes are separate executable, loadable modules (as opposed to threads). One process can’t affect other processes running in same multitasking environment.

Thread: Threads in contrary are the tasks that run concurrently with other tasks within a single executable file.  Within the same process, they can affect each other.  One process can contain any number of threads.

Example: From within a data base application, a user may start both a spell check and a sorting operation.  Contrast this with multiple .EXE files (processes) like a word processor, a data base, and internet browser, multi-tasking under OS/2 for example.

  • What is a Windows Service and how does its lifecycle differ from a "standard" EXE? 

Windows services are long running process (applications) that are ideal for use in server environments. These applications do not have user interface and they do not produce any visual output. Its lifecycle is managed by “Service Control Manager” which is responsible for starting and stopping the service. They do not require a logged in user in order to execute and can run under the context of any user including the system. On the other hand, a “Standard executable” doesn’t require Control Manager and is directly related to the visual output.


  • What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?

Windows provides a page-based virtual memory management scheme that allows applications to realize a 32-bit linear address space for 4 gigabytes (GB) of memory. As a result, each application has its own private address space from which it can use the lower 2 GB—the system reserves the upper 2 GB of every process's address space for its own use.

 Figure: A process in Windows NT has a 4-GB linear address space, of which the lower 2 GB is available for applications to use.

As illustrated in Figure, each process can address up to 4 GB of memory using 32-bit linear addresses. The upper half of the address space is reserved for use by the system. Because the system is the same for each process, regardless of the subsystem it runs on, similar pages of system memory are typically mapped to each process in the same relative location for efficiency.


  • What is the difference between an EXE and a DLL?

DLL is An abbreviation for dynamic link library, a file containing a collection of Windows functions designed to perform a specific class of operations An EXE contains an entry point to start execution { main() in C/C++ and  Public Static Void Main() in .Net  } whereas functions within DLLs are called (invoked) by applications (EXEs) as necessary to perform the desired operation.

  • What is strong-typing versus weak-typing? Which is preferred? Why?

 Strict enforcement of type rules with no exceptions is strong-typing. In a strongly typed language, type usage can be detected at compile time rather then run-time. In these languages, conversion between types requires use of explicit conversion functions as opposed to implicit type coercion in weak-typed (batter called run-typed) languages.

As a common assumption, strong typing catches more errors at compile time than weak typing, resulting in fewer run-time exceptions (but still is a disputable point when it comes to "which one to use").

 

  • Corillian's product is a "Component Container." Name at least 3 component containers that ship now with the Windows Server Family.

Microsoft first announced C# and the .NET Framework in summer 2000, calling C# 'The first component-oriented language in the C/C++ family.'  The essence of component development is not to build what you can buy, on the basis that snapping together pre-tested parts is faster, cheaper and probably more reliable than coding everything for yourself.

As a definition, almost any class file is a component. Moreover, it can easily be compiled to a DLL, it benefits from .NET versioning, and it can be reused. The existence of components also implies the existence of containers, which again may be visual or non-visual. The container plays an important role in component management. In particular, all containers implement IDisposable, which means they have a Dispose method for releasing unmanaged resources such as window handles or open files. In their Dispose method, containers must also call Dispose on all the components they host. In the .NET Framework both ASP.NET Web Forms and rich client Windows Forms are visual component containers.  System.Web.UI.Page, System.Windows.Forms.Form and System.ComponentModel.Container are few other component containers which ship with Windows Server Family.

  • What is a PID? How is it useful when troubleshooting a system?

PID stands for Process Identifier, a uniquely assigned integer that identifies a process in the operating system. In any system, applications use PID to identify the process uniquely. Also, it is used in diagnosing the problems with the process in Multi-Tasking systems.

  • How many processes can listen on a single TCP/IP port?

Probably ONE, if you need to create another TCP/IP listener, you need to set-up a different port.

  • What is the GAC? What problem does it solve?

Each computer on which the common language runtime is installed has a machine-wide code cache called the global assembly cache (GAC). Assemblies deployed in the global assembly cache must have a strong name. A developer tool named "Global Assembly Cache tool" (Gacutil.exe), provided by the .NET Framework SDK can be used to deploy assemblies to GAC. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer. It provides us the way to overcome “DLL Hell” problem also.

         Cheers..

posted on Thursday, March 31, 2005 8:08:00 PM (Central Standard Time, UTC-06:00)  #    Comments [3] Trackback