面试时最经常被问到的问题（Frenquently asked interview questions）之Misc. Topics篇
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Misc. Topics Questions & Answers
1. Differences between Mac, Windows, UNIX
MacOS (up until osX, anyhow) was single-user and (technically) did not have multitasking capabilites (some people will try to tell you that the mac has "cooperative multitasking", but I wouldn't even cosider that multitasking, since it requires each running program to voluntarily pause and wait for others to run).
Windows, starting with Win95 (*) is a single-user, multasking OS. Although newer versions like XP and 2000 support file permissions via EFS, the DO NOT allow multiple users to be logged in at once. (NEWS: win 2003 support this)
UNIX is 100% multi-user and multitasking, and is therefore (why therefore?) inherently stable, secure, and confusing. Once you go UNIX, though, you'll never go back! UNIX (in all caps) was developed by AT&T waaaay back, Unix (no caps) usually refers to a family of operating systems (including the free-but-overrated Linux) that are based on UNIX. Solaris, BSD, OSF, SCO, and Tru64 are all flavors of Unix.
2．How does Windows programming differ from DOS programming?
Windows – GUI DOS - CUI.
Windows - 32bit O.S Dos is 16 bit O.S.
Windows - multithreading and multitasking O.S Dos is stranger to these concepts.
Traditional dos programming is procedural, meaning that your program starts at one place, and steps through the code sequentially.
Windows programming is event-based, meaning that each time an event (like a button-click) occurs; a handler is invoked to produce a response. The difference can be frustrating, since in event-driven code you can inadvertently have several functions running simultaneously on the same data.
3．What is the advantage of Windows?
GUI, Multitasking, Multithreaded O.S., you can also add: supports a vast variety of devices and has a large base of developers and software.
4．What does winmain and wndproc do?
wndmain is the entry point for a win32 app (like main() would be in a dos/unix app). It is used in almost exactly the same way, except that you pass it a lot of worthless params that your code probably won't use anyhow.
wndproc (aka "window procedure") is a function that will be run by your program to process events that occur within it. The wndproc is specified when you call CreateWindow() and usually consists of several nested switch() statements.
5．How does user input are trapped in Windows?
6．Define and explain COM.
COM is a binary standard on Microsoft (and some UNIX platforms) that enables objects to interoperate in a networked environment regardless of the language in which they were developed or on which computers they reside. COM allows an object to expose its functionality to other components and to host applications. It defines both how the object exposes itself and how this exposure works across processes and across networks. COM also defines the object's life cycle.
7．What is IUnknown and what are its three parts?
IUnknown is the Basic COM interface on which all others are based on.
The Three methods of IUnknown are
All the COM interfaces inherit these three methods from IUnknown.
8．What is Marshalling?
Marshalling is the process of converting data into a format for transferring over the network.
9．Differences between Windows 3.1, Windows 95/98, and Windows NT
Windows 3.1 : 16-bit
Windows 9x : 32-bit
Windows NT : 32-bit, more secure, users must login
10．Describe a two tier Windows NT Domain.
11．Describe the file system layout in the UNIX OS.
Bin, boot, dev, etc, home, initrd, lib, lost+found, misc, mnt, opt, proc, root, sbin, tmp, usr, var…
12．In UNIX, are the files allocated contiguous blocks of data?
a) if no, how is the fragmented data kept track of
b) describe the direct blocks and indirect blocks in UNIX file system
13．How is a thread different from a process?
A process runs in its own address space. No two processes share their address space.
Threads will run in the same address space of the process that owns them. Threads belonging to the same process will run in the same address space. They will also share the process's stack and heap. No two processes will share their stacks or their heaps.
14．How is multithreading useful for a web server? A browser?
Web Servers are typically capable of serving multiple clients concurrently, this is achieved using Multi Threading.
15．Why not use multi-process for this? Why would you WANT to run a multi-process web server?
Because if you have a high performance webserver handling thousands of requests, if each of them spawns a new process this creates a lot of overhead. Threads are cheaper.
The reason you use a multi-process web server is for robustness in the face of failure. On a multithreaded server one thread can wipe out all the rest when it crashes the server. In a multi-process server only the offending process goes down. As far as speed is concerned most multi-process servers allow you to spawn at the beginning any number of processes to handle requests so speed differences on a running system are not much different between multi-threading and multi-process servers.
16．What locking constructs are available on platform X (NT = semaphore, critical section, mutex), What are the main differences between them?
17．Familiar with multi-reader, single writer locks?
18．How could you implement that given a simple binary semaphore OS construct?
19．How does this implementation behave? Can it starve readers? Starve writers?