<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Free Question Bank &#187; OS</title> <atom:link href="http://www.freequestionbank.com/category/tech-crunch/operating-system/feed/" rel="self" type="application/rss+xml" /><link>http://www.freequestionbank.com</link> <description>Just another WordPress weblog</description> <lastBuildDate>Sat, 20 Feb 2010 05:10:08 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.1</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Unix Interview Questions</title><link>http://www.freequestionbank.com/question/unix-interview-questions/</link> <comments>http://www.freequestionbank.com/question/unix-interview-questions/#comments</comments> <pubDate>Thu, 26 Mar 2009 07:49:07 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Interview]]></category> <category><![CDATA[OS]]></category> <category><![CDATA[Question]]></category> <category><![CDATA[unix]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/?p=428</guid> <description><![CDATA[Q: How would you make the following SQL statement run faster? SELECT * FROM TABLEA WHERE COL1=’A’ AND COL2=’B&#8217;;
A: ...]]></description> <content:encoded><![CDATA[<p><span
class="Apple-style-span" style="border-collapse: collapse; color: #000000; font-family: 'times new roman'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Q: How would you make the following SQL statement run faster? SELECT * FROM TABLEA WHERE COL1=’A’ AND COL2=’B&#8217;;<span
class="Apple-converted-space"> </span><br
/> </span></strong><span
style="font-size: x-small;">A: Make sure that COL1 and COL2 have indexes.<br
/> Find out which condition will return less values and use that as the first conditonal.</span></span></span></p><p><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Q: What is Data Mining<span
class="Apple-converted-space"> </span><br
/> </span></strong><span
style="font-size: x-small;">A: Data Minig is the process of sifting through extremeley large amounts of Data to find trends or relevent information.</span></span></p><p><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Q: Name the Seven layers in the OSI Model.<span
class="Apple-converted-space"> </span><br
/> </span></strong><span
style="font-size: x-small;">A: Appication, Presentation, Session, Transport, Network, Data Link, Phyiscal</span></span></p><p><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Q: What is one way to view a unix network share on a Windows computer, within explorer<span
class="Apple-converted-space"> </span><br
/> </span></strong><span
style="font-size: x-small;">A: NFS, The Unix computer can be running a NFS Server Daemon.</span></span></p><p><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Q: How would you find all the processes running on your computer.<span
class="Apple-converted-space"> </span><br
/> </span></strong><span
style="font-size: x-small;">A: Unix, is ps -ef or ps -aux depending on version.</span></span></p><p><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Q: What is DHCP<span
class="Apple-converted-space"> </span><br
/> </span></strong><span
style="font-size: x-small;">A: DHCP is a way to dynamically assign IP address to computers. Dyanmic Host Configuration Protocol</span></span></p><p><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Q: What is HTTP Tunneling<span
class="Apple-converted-space"> </span><br
/> </span></strong><span
style="font-size: x-small;">A: HTTP Tunneling is a security method that encryptes packets traveling throught the internet. Only the intended reciepent should be able to decrypt the packets. Can be used to Create Virtual Private Networks. (VPN)</span></span></p><p><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Q: Scenario: You have 9 identical looking balls, however one ball is heavier than the others. You have two chances to use a balance. How do you find out which ball is the heaviest?<span
class="Apple-converted-space"> </span><br
/> </span></strong><span
style="font-size: x-small;">A: Split into groups of three, randomly choose two groups and use balance on them. If one group is heavier, then discard the other 6 balls. If the two groups are the same weight. The heavier ball must be in the group that was not on the scale. Now randomly choose two balls and test on balance. If they are the same weight, the heaviest ball is on one that was not tested. Else the heaviest ball is already known from the balance.</span></span></p><p>* more <a
href="planetetutors.com">here</a></p> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/question/unix-interview-questions/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Window Interview Questions</title><link>http://www.freequestionbank.com/question/window-interview-questions/</link> <comments>http://www.freequestionbank.com/question/window-interview-questions/#comments</comments> <pubDate>Thu, 26 Mar 2009 07:48:06 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Interview]]></category> <category><![CDATA[OS]]></category> <category><![CDATA[Question]]></category> <category><![CDATA[windows]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/?p=426</guid> <description><![CDATA[What are kernel objects? - - Several types of kernel objects, such as access token objects, event objects, file objects, ...]]></description> <content:encoded><![CDATA[<table
id="AutoNumber1" class="zeroBorder" style="height: 354px;" border="0" cellspacing="0" cellpadding="0" width="100%" bordercolor="#111111"><tbody><tr><td
width="97%" height="240" valign="top"><ol><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What are kernel objects? -</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Several types of kernel objects, such as access token objects, event objects, file objects, file-mapping objects, I/O completion port objects, job objects, mailslot objects, mutex objects, pipe objects, process objects, semaphore objects, thread objects, and waitable timer objects.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is a kernel object?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Each kernel object is simply a memory block allocated by the kernel and is accessible only by the kernel. This memory block is a data structure whose members maintain information about the object. Some members (security descriptor, usage count, and so on) are the same across all object types, but most are specific to a particular object type. For example, a process object has a process ID, a base priority, and an exit code, whereas a file object has a byte offset, a sharing mode, and an open mode.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">User can access these kernel objects structures?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Kernel object data structures are accessible only by the kernel</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">If we cannot alter these Kernel Object structures directly, how do our applications manipulate these kernel objects?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- The answer is that Windows offers a set of functions that manipulate these structures in well-defined ways. These kernel objects are always accessible via these functions. When you call a function that creates a kernel object, the function returns a handle that identifies the object.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">How owns the Kernel Object?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Kernel objects are owned by the kernel, not by a process</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">How does the kernel object outlive the process that created it?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- If your process calls a function that creates a kernel object and then your process terminates, the kernel object is not necessarily destroyed. Under most circumstances, the object will be destroyed; but if another process is using the kernel object your process created, the kernel knows not to destroy the object until the other process has stopped using it</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Which is the data member common to all the kernel object and what is the use of it?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>-</span></span><span
style="font-weight: 400;"><span
style="font-size: x-small;"> The usage count is one of the data members common to all kernel object types</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">How to identify the difference between the kernel object and user object?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>-</span></span><span
style="font-weight: 400;"><span
style="font-size: x-small;"> The easiest way to determine whether an object is a kernel object is to examine the function that creates the object. Almost all functions that create kernel objects have a parameter that allows you to specify security attribute information.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is the purpose of Process Handle Table?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>-</span></span><span
style="font-weight: 400;"><span
style="font-size: x-small;">When a process is initialized, the system allocates a handle table for it. This handle table is used only for kernel objects, not for User objects or GDI objects. When a process first initializes, its handle table is empty. Then when a thread in the process calls a function that creates a kernel object, such as<span
class="Apple-converted-space"> </span><em>CreateFileMapping</em><span
class="Apple-converted-space"> </span>, the kernel allocates a block of memory for the object and initializes it; the kernel then scans the process’s handle table for an empty entry</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Name few functions that create Kernel Objects?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- HANDLE CreateThread(…),HANDLE CreateFile(..),HANDLE CreateFileMapping(..)HANDLE CreateSemaphore(..)etcAll functions that create kernel objects return process-relative handles that can be used successfully by any and all threads that are running in the same process.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is handle?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Handle value is actually the index into the process’s handle table that identifies where the kernel object’s information is stored.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">How the handle helps in manipulating the kernel objects?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Whenever you call a function that accepts a kernel object handle as an argument, you pass the value returned by one of the<span
class="Apple-converted-space"> </span><em>Create*</em><span
class="Apple-converted-space"> </span>functions. Internally, the function looks in your process’s handle table to get the address of the kernel object you want to manipulate and then manipulates the object’s data structure in a well-defined fashion.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What happens when the CloseHandle(handle) is called?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- This function first checks the calling process’s handle table to ensure that the index (handle) passed to it identifies an object that the process does in fact have access to. If the index is valid, the system gets the address of the kernel object’s data structure and decrements the usage count member in the structure; if the count is zero, the kernel destroys the kernel object from memory.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">You forget to call<span
class="Apple-converted-space"> </span><em>CloseHandle</em><span
class="Apple-converted-space"> </span>- will there be a memory leak?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Well, yes and no. It is possible for a process to leak resources (such as kernel objects) while the process runs. However, when the process terminates, the operating system ensures that any and all resources used by the process are freed—this is guaranteed. For kernel objects, the system performs the following actions: When your process terminates, the system automatically scans the process’s handle table. If the table has any valid entries (objects that you didn’t close before terminating), the system closes these object handles for you. If the usage count of any of these objects goes to zero, the kernel destroys the object.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is the need of process relative handles?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- The most important reason was robustness. If kernel object handles were system-wide values, one process could easily obtain the handle to an object that another process was using and wreak havoc on that process. Another reason for process-relative handles is security. Kernel objects are protected with security, and a process must request permission to manipulate an object before attempting to manipulate it. The creator of the object can prevent an unauthorized user from touching the object simply by denying access to it</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">How the handles are handled in the child process?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- The operating system creates the new child process but does not allow the child process to begin executing its code right away. Of course, the system creates a new, empty process handle table for the child process—just as it would for any new process. But because you passed TRUE to<span
class="Apple-converted-space"> </span><em>CreateProcess</em>’s<em>bInheritHandles</em><span
class="Apple-converted-space"> </span>parameter, the system does one more thing: it walks the parent process’s handle table, and for each entry it finds that contains a valid inheritable handle, the system copies the entry exactly into the child process’s handle table. The entry is copied to the exact same position in the child process’s handle table as in the parent’s handle table.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Why the entries in the parent process table and child table are same?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- It means that the handle value that identifies a kernel object is identical in both the parent and the child processes.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What about the usage count in the parent child process tables?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- The system increments the usage count of the kernel object because two processes are now using the object. For the kernel object to be destroyed, both the parent process and the child process must either call<span
class="Apple-converted-space"> </span><em>CloseHandle</em><span
class="Apple-converted-space"> </span>on the object or terminate.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What are Named Objects?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Method available for sharing kernel objects across process boundaries is to name the objects. Below are the kernel named objects 1) mutex, 2) Events, 3) semaphore, 4) waitableTimers, 5)file mapping, 6)job object. There are APIs to create these objects with last parameter as the object name.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What do you mean by unnamed object?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- When you are creating the kernel objects with the help of API’s like CreateMutex(, , , ,pzname). And the Pzname parameter is NULL , you are indicating to the system that you want to create an unnamed (anonymous) kernel object. When you create an unnamed object, you can share the object across processes by using either inheritance or<span
class="Apple-converted-space"> </span><em>DuplicateHandle</em></span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is DuplicateHandle (API)?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Takes an entry in one process’s handle table and makes a copy of the entry into another process’s handle table</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is a thread?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- A thread describes a path of execution within a process. Every time a process is initialized, the system creates a primary thread. This thread begins executing with the C/C++ run-time library’s startup code, which in turn calls your entry-point function (<span
class="Apple-converted-space"> </span><em>main</em><span
class="Apple-converted-space"> </span>,<span
class="Apple-converted-space"> </span><em>Wmain</em><span
class="Apple-converted-space"> </span>,<span
class="Apple-converted-space"> </span><em>WinMain</em><span
class="Apple-converted-space"> </span>, or<span
class="Apple-converted-space"> </span><em>WWinMain</em><span
class="Apple-converted-space"> </span>) and continues executing until the entry-point function returns and the C/C++ run-time library’s startup code calls<span
class="Apple-converted-space"> </span><em>ExitProcess</em></span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is the limit on per process for creating a thread?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- The number of threads a process can create is limited by the available virtual memory and depends on the default stack size</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is Synchronization Objects?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>-<span
class="Apple-converted-space"> </span><em>Synchronization object</em><span
class="Apple-converted-space"> </span>s are use to co-ordinate the execution of multiple threads.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">Which kernel objects are use for Thread Synchronization on different processes?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Event, Mutex, Semaphore</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is Event Object and why it is used?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Event is the thread synchronization object to set signaled state or non-signaled state.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is signaled and non signaled state?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- An event is in signaled state means that it has the capacity to release the threads waiting for this event to be signaled. An event is in non signaled state means that it will not release any thread that is waiting for this particular event.example in our project: when user clicks the image application icon double simultaneously. Two image application windows were created. so PAIG created an event and set it to non-signaled state. Then the image application will reset the event to signaled state, after this all the threads are released.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">APIs for creating event and set and reset the events</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- CreateEvent-to create the event OpenEvent – to open already created event SetEvent – to set the event signaled stateRestEvent &#8211; To set the Event To non-Signaled State</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is Mutex Object and why it is used?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- A<span
class="Apple-converted-space"> </span><em>mutex object</em><span
class="Apple-converted-space"> </span>is a synchronization object whose state is set to signaled when it is not owned by any thread, and non-signaled when it is owned. For example, to prevent two threads from writing to shared memory at the same time, each thread waits for ownership of a mutex object before executing the code that accesses the memory. After writing to the shared memory, the thread releases the mutex object.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">How do I create a Mutex?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- A thread uses the<span
class="Apple-converted-space"> </span><strong>CreateMutex</strong><span
class="Apple-converted-space"> </span>function to create a mutex object. The creating thread can request immediate ownership of the mutex object and can also specify a name for the mutex object</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">How do other threads own the mutex?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- Threads in other processes can open a handle to an existing named mutex object by specifying its name in a call to the<strong>OpenMutex</strong><span
class="Apple-converted-space"> </span>- function. Any thread with a handle to a mutex object can use one of the wait functions to request ownership of the mutex object. If the mutex object is owned by another thread, the wait function blocks the requesting thread until the owning thread releases the mutex object using the<strong>ReleaseMutex</strong><span
class="Apple-converted-space"> </span>- function.</span></span></li><li><span
style="font-weight: 400;"><strong><span
style="font-size: x-small;">What is semaphores and why it is used?</span></strong><span
style="font-size: x-small;"><span
class="Apple-converted-space"> </span>- A semaphore object is a synchronization object that maintains a count between zero and a specified maximum value. The count is decremented each time a thread completes a wait for the semaphore object and incremented each time a thread releases the semaphore. When the count reaches zero, no more threads can successfully wait for the semaphore object state to become signaled. The state of a semaphore is set to signaled when its count is greater than zero, and non-signaled when its count is zero. The semaphore object is useful in controlling a shared resource that can support a limited number of users. It acts as a gate that limits the number of threads sharing the resource to a specified maximum number. For example, an application might place a limit on the number of windows that it creates. It uses a semaphore with a maximum count equal to the window limit, decrementing the count whenever a window is created and incrementing it whenever a window is closed. The application specifies the semaphore object in call to one of the wait functions before each window is created. When the count is zero &#8211; indicating that the window limit has been reached &#8211; the wait function blocks execution of the window-creation code.</span></span></li></ol></td></tr></tbody></table><p>* more <a
href="planetetutors.com">here</a></p> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/question/window-interview-questions/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Charsets and Endian-ness</title><link>http://www.freequestionbank.com/tech-crunch/operating-system/charsets-and-endian-ness/</link> <comments>http://www.freequestionbank.com/tech-crunch/operating-system/charsets-and-endian-ness/#comments</comments> <pubDate>Wed, 11 Mar 2009 06:23:45 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Languages]]></category> <category><![CDATA[OS]]></category> <category><![CDATA[bigendian]]></category> <category><![CDATA[byteorder]]></category> <category><![CDATA[charset]]></category> <category><![CDATA[encoding]]></category> <category><![CDATA[java]]></category> <category><![CDATA[littleendian]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/?p=191</guid> <description><![CDATA[A character set, also known as an &#8220;encoding,&#8221; is the set of bit patterns used to represent a set of ...]]></description> <content:encoded><![CDATA[<p>A character set, also known as an &#8220;encoding,&#8221; is the set of bit patterns used to represent a set of characters. EBCDIC is used in IBM mainframs. ASCII is one of the most popular encoding. Unicode is the third encoding.</p><p>Endian-ness refers to the order in memory in which bytes are stored for a multiple byte quantity.</p><p>All modern computer architectures are byte-addressable, meaning every byte of main memory has a unique address. If you store multibyte datum in several successive addresses, should the most significant byte (MSB) of the datum go at highest address or the lowest address?</p><p><strong>Big Endian</strong>, means that the MSB of an integer is stored at the lowest address, and the least significant byte (LSB) at the highest address (The Big End comes first).</p><p><strong>0&#215;11223344 is stored as below:</strong></p><p>base address+0:0&#215;11<br
/> base address+1:0&#215;22<br
/> base address+2:0&#215;33<br
/> base address+3:0&#215;44</p><p><strong>Usage:</strong> The APARC, Motorola 68K and the IBM 390 series are all big-endian architecture.</p><p><strong>Advantage:</strong> telling if a number is +ve or -ve by just looking at the first byte.</p><p> </p><p> </p><p><strong>Little Endian</strong>, means that the LSB of an integer is stored at the lowest address, and the MSB at the highest address (The Little End comes first).</p><p><strong>0&#215;11223344 is stored as below:</strong></p><p>base address+0:0&#215;44<br
/> base address+1:0&#215;33<br
/> base address+2:0&#215;22<br
/> base address+3:0&#215;11</p><p><strong>Usage:</strong> Intel x86 and DEC VAX are all little-endian architecture.</p><p><strong>Advantage:</strong> telling if a number is odd or even by just looking at the first byte.</p><div></div><div>Java uses Big-Endian ordering when it processes data, regardless of the platform it is on. Big Endian is also known as &#8220;network byte order&#8221; because it is used in TCP/IP standard.</div><div></div><div>The only time endian-ness is an issue when you are trying to read data that was written by a non-java program on PC. Then you have to remember to swap multibyte values on the way in, or swap a buffer around an array.</div><div></div><div>                                MS Windows      Unix</div><div>                                &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</div><div>Newline                \r\n                    \n</div><div>Filename sep      \                   /</div><div>Data byte order Little endian         Varies with Hardware</div><div></div><div>source: Freequestionbank.com</div> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/tech-crunch/operating-system/charsets-and-endian-ness/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Creating shared &amp; static library using gnu compiler</title><link>http://www.freequestionbank.com/tech-crunch/creating-a-shared-and-static-library-with-the-gnu-compiler/</link> <comments>http://www.freequestionbank.com/tech-crunch/creating-a-shared-and-static-library-with-the-gnu-compiler/#comments</comments> <pubDate>Tue, 10 Mar 2009 23:29:56 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[OS]]></category> <category><![CDATA[Tech]]></category> <category><![CDATA[dll]]></category> <category><![CDATA[unix]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/?p=181</guid> <description><![CDATA[
The code for the library
calc_mean.c
//#include &#60;stdio.h&#62;##N(mean)
double mean(double a, double b) {
return (a+b) / 2;
}
The header file
Of course, we ...]]></description> <content:encoded><![CDATA[<div
class="entry"><h2>The code for the library</h2><p
class="filename">calc_mean.c</p><pre class="code">//#include &lt;stdio.h&gt;

##N(mean)
double <strong>mean</strong>(double a, double b) {
  return (a+b) / 2;
}</pre><h3 id="calc_mean_h">The header file</h3><p
class="txt">Of course, we need a header file.</p><p
class="filename">calc_mean.h</p><pre class="code">double mean(double, double);</pre><h3>Creating the static library</h3><p
class="txt">A static library is basically a set of <strong>object files</strong> that were copied<br
/> into a single file. This single file is the static library. The static     file<br
/> is created with the <a
href="http://www.adp-gmbh.ch/cpp/gcc/ar.html">archiver (ar)</a>.</p><p
class="txt">First, calc_mean.c is turned into an object file:</p><pre class="code">gcc <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_c">-c</a> calc_mean.c <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_o">-o</a> calc_mean.o</pre><p
class="txt">Then, the archiver (ar) is invoked to produce a static library<br
/> (named libmean.a) out of the object file calc_mean.o.</p><pre class="code"><a href="http://www.adp-gmbh.ch/cpp/gcc/ar.html">ar</a>  rcs libmean.a      calc_mean.o</pre><p
class="txt">Note: the library must start with the three letters <em>lib</em> and have the suffix <strong>.a</strong>.</p><h3 id="shared">Creating the shared library</h3><p
class="txt">As with static libraries, an object file is created. The <a
href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_f_cap_pic">-fPIC</a> option tells gcc to create position independant code which is necessary for shared libraries. Note also, that the object file created for the static library will be overwritten. That’s not bad, however, because we have a static library that already contains the needed object file.</p><pre class="code">gcc <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_c">-c</a> <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_f_cap_pic">-fPIC</a> calc_mean.c -o calc_mean.o</pre><p
class="txt">For some reason, gcc says:</p><pre class="out">cc1: warning: -fPIC ignored for target</pre><pre class="out">(all code is position independent)</pre><p
class="txt">It looks like -fPIC is not necessary on x86, but all manuals say,<br
/> it’s needed, so I use it too.</p><p
class="txt">Now, the shared library is created</p><pre class="code">gcc <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_shared">-shared</a> <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_cap_w_l">-Wl</a>,-soname,libmean.so.1 <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_o">-o</a></pre><pre class="code">libmean.so.1.0.1  calc_mean.o</pre><p
class="txt">Note: the library must start with the three letter <strong>lib</strong>.</p><h2>The programm using the library</h2><p
class="txt">This is the program that uses the <strong>calc_mean</strong> library. Once, we<br
/> will link it against the static library and once against the shared library.</p><p
class="filename">main.c</p><pre class="code">#include &lt;stdio.h&gt;
#include "<a href="http://www.adp-gmbh.ch/cpp/gcc/create_lib.html#calc_mean_h">calc_mean.h</a>”

int main(int argc, char* argv[]) {

  double v1, v2, m;
  v1 = 5.2;
  v2 = 7.9;

  m  = <a href="http://www.adp-gmbh.ch/cpp/gcc/create_lib.html#mean">mean</a>(v1, v2);

  printf(”The mean of %3.2f and %3.2f
is %3.2f\n”, v1, v2, m);

  return 0;
}</pre><h3>Linking against static library</h3><pre class="code">gcc <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_static">-static</a> main.c <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_cap_l">-L</a>. <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_l">-l</a>mean <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_o">-o</a> statically_linked</pre><p
class="txt">Note: the first three letters (the <strong>lib</strong>) must not be specified,<br
/> as well as the suffix (<strong>.a</strong>)</p><h3>Linking against shared library</h3><pre class="code">gcc main.c <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_o">-o</a> dynamically_linked <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_cap_l">-L</a>. <a href="http://www.adp-gmbh.ch/cpp/gcc/gcc_options.html#opt_l">-l</a>mean</pre><p
class="txt">Note: the first three letters (the <strong>lib</strong>) must not be specified,<br
/> as well as the suffix (<strong>.so</strong>)</p><h3>Executing the dynamically linked programm</h3><pre class="code">LD_LIBRARY_PATH=.
./dynamically_linked</pre><h2><a
title="ss6.2" name="ss6.2"></a>Interrogating libraries (`which library is <code>sin()</code> in?’)</h2><p><code>nm </code><em>libraryname</em> should list all the symbols that <em>libraryname</em> has references to.  It works on both static and shared libraries.  Suppose that you want to know where <code>tcgetattr()</code> is defined: you might do</p><blockquote><p><code> </code></p><pre>$ nm libncurses.so.1 |grep tcget
         U tcgetattr</pre></blockquote><p>The <code>U</code> stands for `undefined’ — it shows that the ncurses library uses but does not define it.  You could also do</p><blockquote><p><code> </code></p><pre>$ nm libc.so.5 | grep tcget
00010fe8 T __tcgetattr
00010fe8 W tcgetattr
00068718 T tcgetpgrp</pre></blockquote><p>The `<code>W</code>‘ stands for `weak’, which means that the symbol is defined, but in such a way that it can be overridden by another definition in a different library. A straightforward `normal’ definition (such as the one for <code>tcgetpgrp</code>) is marked by a `<code>T</code>‘</p><p><a
title="index.70" name="index.70"></a></p><p>The short answer to the question in the title, by the way, is <code>libm.(so|a)</code>.  All the functions defined in <code>&lt;math.h&gt;</code> are kept in the maths library; thus you need to link with <code>-lm</code> when using any of them.</p><h2><a
title="ss6.3" name="ss6.3"></a>Finding files</h2><p><code>ld: Output file requires shared library `libfoo.so.1`</code></p><p>The file search strategy of ld and friends varies according to version, but the only default you can reasonably assume is <code>/usr/lib</code>.  If you want libraries elsewhere to be searched, specify their directories with the <code>-L</code> option to gcc or ld.</p><h3>ELF shared libraries</h3><p>To build <code>libfoo.so</code> as a shared library, the basic steps look like this:</p><blockquote><p><code> </code></p><pre>$ gcc -fPIC -c *.c
$ gcc -shared -Wl,-soname,libfoo.so.1
-o libfoo.so.1.0 *.o
$ ln -s libfoo.so.1.0 libfoo.so.1
$ ln -s libfoo.so.1 libfoo.so
$ LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH ;
export LD_LIBRARY_PATH</pre></blockquote></div> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/tech-crunch/creating-a-shared-and-static-library-with-the-gnu-compiler/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- This site's performance optimized by W3 Total Cache. Dramatically improve the speed and reliability of your blog!

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 7/13 queries in 0.163 seconds using disk

Served from: p3slh049.shr.phx3.secureserver.net @ 2010-09-09 23:13:13 -->