Академический Документы
Профессиональный Документы
Культура Документы
List the four major differences between Web and Windows applications.
Web forms cannot use the standard Windows controls. Instead, they use server controls, HTML
controls, user controls, or custom controls created specially for Web forms.
Web applications are displayed in a browser. Windows applications display their own windows
and have more control over how those windows are displayed.
Web forms are instantiated on the server, sent to the browser, and destroyed immediately.
Windows forms are instantiated, exist for as long as needed, and are destroyed.
Web applications run on a server and are displayed remotely on clients. Windows applications
run on the same machine they are displayed on.
Describe the life cycle of a Web application: When are Web forms instantiated and how long do
they exist?
A Web application starts with the first request for a resource within the application’s boundaries. Web
forms are instantiated when they are requested. They are processed by the server and are abandoned
immediately after the server sends its response to the client. A Web application ends after all client
sessions end.
How do you preserve persistent data, such as simple variables, in a Web application?
You can preserve data in state variables, such as ApplicationState, SessionState, or ViewState.
In Visual Basic .NET, what is the difference between a class module and a code module?
Class modules are instantiated at run time to create objects that provide separate storage for variables
and properties in each instance. Code modules do not have instances, so any module-level variables
they use are shared among calls to the module’s procedures.
In Visual C#, how do you declare a method to make it available without having to first instantiate
an object from the class?
To create a method that can be called without instantiating an object, declare that method as static.
How do you call a member of a base class from within a derived class?
To refer to a member of a base class in Visual Basic .NET, use the MyBase keyword. To refer to a
member of a base class in Visual C#, use the base keyword.
Where would you save the following data items so that they persist between requests to a Web
form?
What is the main difference between the Button server control and the Button HTML control?
When clicked, the Button server control triggers an ASP.NET Click event procedure on the server. The
Button HTML control triggers the event procedure indicated in the button’s onclick attribute, which runs
on the client.
How do you get several RadioButton controls to interoperate on a Web form so that only one of
the RadioButton controls can have a value of True/true at any given time?
Set the GroupName property of each RadioButton to the same name.
Why does ASP.NET perform validation on both the client and the server?
Client-side validation helps avoid round-trips to the server. Validating on the client ensures that the data
is valid before it is submitted, in most cases. However, because validation might be turned off (or
maliciously hacked) on the client, data must be revalidated on the server side. This provides full
assurance that the data is valid while avoiding as many round-trips as possible.
What types of validation would you use to verify that a user entered a valid customer number?
You would use a RequiredFieldValidator and a RegularExpressionValidator. If you have access to a list
of expected customer numbers, you could replace the RegularExpressionValidator with a
CustomValidator that checked the list.
Why can’t you open a new browser window from within server code?
Server code executes on the server, whereas the new window is created on the client. You need to use
client-side code to do things that affect the client, such as upload files, display new windows, or navigate
back in history.
What steps would you follow and what objects would you use to quickly find the number of
records in a database table?
There are two ways to accomplish this task:
Use a database connection and a command object to execute a SQL command that re-turns the
number of rows in the table.
Use a database connection and data adapter object to create a data set for the table, and then
get the number rows in the data set.
How do typed data sets differ from untyped data sets, and what are the advantages of typed data
sets?
Typed data sets use explicit names and data types for their members, whereas untyped data sets use
collections to refer to their members. The following examples show a typed reference vs. an untyped
reference to a data item:
// Typed reference to the Contacts table's HomePhone column.
DataSet1.Contacts.HomePhoneColumn.Caption = "@Home";
// Untyped reference to the Contacts table's HomePhone column.
DataSet1.Tables["Contacts"].Columns["HomePhone"].Caption = "@Home";
Typed data sets do error checking at design time. This error checking helps catch typos and type
mismatch errors, which would be detected only at run time with untyped data sets.
Explain the difference between handling transactions at the data set level and at the database
level.
Data sets provide implicit transactions, because changes to the data set aren’t made permanent in the
database until you call the Update method. To handle transactions in a data set, process the Update
method and check for errors. If errors occur during an update, none of the changes from the data set is
made in the database. You can try to correct the error and resubmit the update, or you can roll back the
changes to the data set using the RejectChanges method.
Databases provide explicit transactions through the Transaction object. You create a Transaction object
from a database connection and then assign that Transaction object to the commands you want to
include in the transaction through the command object’s Transaction property. As you perform the
commands on the database, you check for errors. If errors occur, you can either try to correct them and
resubmit the command, or you can restore the state of the database using the Transaction object’s
RollBack method. If no errors occur, you can make the changes permanent by calling the transaction
object’s Commit method.
Describe the purpose of error pages and why they are needed.
Because Web applications run over the Internet, some exceptions occur outside the scope of the
application. This means that your application can’t respond directly to these exceptions. These types of
exceptions are identified by HTTP response codes, which IIS can respond to by displaying custom error
pages listed in your application’s Web.config file.
Write the HTML for a hyperlink that will send mail when the user clicks the link.
<a href="mailto:you@pragim.com?SUBJECT=Sending from a client&BODY=Some message text.">
Send mail </a>
Write the code that creates a cookie containing the user name Rob Young and the current date to
the user’s computer. Set the cookie to remain on the user’s computer for 30 days.
HttpCookie cookUserInfo = new HttpCookie("UserInfo");
CookUserInfo["Name"] = "Rob Young";
CookUserInfo["Time"] = DateTime.Now.ToString();
cookUserInfo.Expires = DateTime.Now.AddDays(30);
Response.Cookies.Add(cookUserInfo);
What attribute do you use to hide a public .NET class from COM?
Use the ComVisible attribute to select which public .NET classes and members are visible to COM. This
attribute applies hierarchically for the assembly, class, and member levels.
Why can’t you open a new browser window using server-side code? How would you display a
page in a new window with a client-side script?
Server-side code can execute tasks only on the server. To perform a task on the client’s computer, such
as opening a new browser window, the code needs to run on the client.
You can open a new window using the DOM window object. For example, the following HTML Button
control opens a Help page in a new window:
< button id="butHelp" onclick="window.open('help.aspx', 'help', 'height=200,width=300')" > Help </
button>
Which ASP.NET authentication mode is best suited to identifying and authorizing users who
belong to a corporate network?
Windows authentication is best suited to authenticating users of a corporate network because it uses the
accounts and permissions that already exist for network users.
What is the difference between Windows and Forms authentication user lists in Web.config?
User lists for Windows authentication are included in the <authorization> element of Web.config. User
lists for Forms authentications are included in the <credentials> element of Web.config or as part of an
external users database or file.
How do you run a Web application using the permission set of an authenticated user?
Use the identity element in Web.config to execute code using the authenticated user’s account. For
example:
<!-- Impersonate the authenticated user -->
<identity impersonate="true" />
How does the Secure Sockets Layer (SSL) provide security in a Web application?
SSL protects data exchanged between a client and a Web application by encrypting the data before it is
sent across the Internet.
How do you configure a setup project to install an application over the Web?
To configure a setup project to install an application over the Web, select the Web Bootstrapper option
from the setup project’s properties. This setting allows the Windows Installerto be downloaded and
installed over the Web.
How does deploying to a Web farm or a Web garden affect Session state in a Web application?
Web applications that are deployed to a Web farm or a Web garden need to identify a Session state
provider in their Web.config file. This is because a single client’s requests can be directed to different
processes over the course of his or her session. The Session state provider allows each different process
to access the client’s Session state.
Why is load testing likely to be more important for a Web application than for a stand-alone
Windows application?
Because Web applications can be public on the Internet, they can have hundreds, thousands, or even
millions of users. Load tests let you simulate the expected demand to locate resource conflicts,
performance bottlenecks, and other problems that aren’t apparent in single-user tests.
What are the two special steps you need to take to ensure that a COM component can use a
component from a .NET assembly?
To use a .NET component from a COM tool, such as VBScript, you must:
Register the .NET assembly in the system registry using RegAsm.exe.
Make sure that the COM component can find the .NET assembly, either by placing the .NET
assembly in the global assembly cache, by placing the two components in the same folder, or by
following the other assembly-probing rules.
What is the most important method to override when you’re creating a composite custom
control?
You override the CreateChildControls method to add existing controls to a composite custom control.
How is raising a post-back event in a composite control different from raising a post-back event
in a rendered control?
In a composite control, you can use one of the contained controls to raise a post-back event. In a
rendered control, you must implement the IPostBackEventHandler interface and write a client-side script
to raise a post-back event.
Write a directive to cache responses for a Web form for 30 seconds, storing different cache
responses based on the value of the lstNames control.
<%@ OutputCache Duration=”30” VaryByParam=”lstNames” %>
A Web form uses fragment caching to store a frequently used user control. At run time, an Object
not found error occurs whenever the page is refreshed. What is a likely cause of the error?
The most likely cause is that the user control is referenced in code after it has been cached. Once
cached, a user control’s properties and methods are no longer available.
How can you detect when application data is about to be removed from the cache?
Use the onRemoveCallback delegate.
What is the advantage of using CSS rather than in-line styles for formatting a Web application?
Using CSS allows you to maintain formatting separately from the content of your Web forms, so changes
are easier to make and consistency is easier to maintain.
Why would you create a style for a class rather than for an HTML element?
You create style classes when you want to apply the same formatting to different types of elements within
an application. For example, you might want to create an emphasis style class that applies the same
formatting to any text, control, heading, or image that you want to draw the user’s attention to.
How do CSS and XSL relate to each other when it comes to formatting a Web application?
CSS and XSL are complementary techniques for formatting. CSS determines the font, color, size,
background, and other appearance aspects of HTML elements on a Web page. XSL is used to transform
XML files into HTML output. In this way, XSL controls the position and appearance of items based on
their content. Used together, XSL performs the high-level tasks of composition and layout while CSS
performs the low-level tasks of applying fonts, colors, and other appearance features
Which HTML attribute does the server control’s ToolTip property map to in the HTML rendered by
ASP.NET?
The ToolTip property is rendered as the title attribute at run time.
What is the difference between the CurrentCulture property and the Current UICulture property?
The CurrentCulture property affects how the .NET Framework handles dates, currencies, sorting, and
formatting issues. The CurrentUICulture property determines which satelliteassembly is used when
loading resources.
Value Types which include simple types (e.g., char, int, and float), enum types, and struct types
Reference Types which class types, interface types, delegate types, and array types
What is a Windows Service and how does its lifecycle differ from a “standard” EXE?
Windows service cannot be installed on Win9x machines even though the .NET framework runs on
machine.
| 0 Comments |
Can you give an example of when it would be appropriate to use a web service as opposed to non-
serviced .NET component
Web service is one of main component in Service Oriented Architecture. You could use web services
when your clients and servers are running on different networks and also different platforms. This
provides a loosely coupled system. And also if the client is behind the firewall it would be easy to use
web service since it runs on port 80 (by default) instead of having some thing else in Service Oriented
Architecture applications.
What is the transport protocol you use to call a Web service SOAP
HTTP with SOAP
True or False: To test a Web service you must create a windows application or Web application to
consume this service?
False.
2. Synchronous Call
Application has to wait until execution has completed.
<dynamicdiscovery
xmlns="urn:schemas-dynamicdiscovery:disco.2000-03-17">
</dynamicdiscovery
<%
Response.Cache.SetNoStore ();
Response.Write (DateTime.Now.ToLongTimeString ());
%>
SetNoStore works by returning a Cache-Control: private, no-store header in the HTTP response. In this
example, it prevents caching of a Web page that shows the current time.
What is the difference between Debug.Write and Trace.Write? When should each be used?
The Debug.Write call won’t be compiled when the DEBUGsymbol is not defined (when doing a release
build). Trace.Write calls will be compiled. Debug.Write is for information you want only in debug builds,
Trace.Write is for when you want it in release build as well.
Can you write a class without specifying namespace? Which namespace does it belong to by default?
Yes, you can, and then the class belongs to global namespace which has no name. For commercial
products, naturally, you wouldn’t want global namespace.
You are designing a GUI application with windows and several widgets on it. The user then resizes the
app window and sees a lot of grey space, while the widgets stay in place. What’s the problem?
One should use anchoring for correct resizing. Otherwise the default property of a widget on a form is
top-left, so it stays at the same location when resized.
How can you save the desired properties of Windows Forms application?
.config files in .NET are supported through the API to allow storing and retrieving information. They are
nothing more than simple XML files, sort of like what .ini files were before for Win32 apps.
So how do you retrieve the customized properties of a .NET application from XML .config file?
Initialize an instance of AppSettingsReader class. Call the GetValue method of AppSettingsReader class,
passing in the name of the property and the type expected. Assign the result to the appropriate variable.
My progress bar freezes up and dialog window shows blank, when an intensive background process
takes over.
Yes, you should’ve multi-threaded your GUI, with taskbar and main form being one thread, and the
background process being the other.
Why is it not a good idea to insert code into InitializeComponent method when working with Visual
Studio?
The designers will likely through it away, most of the code inside InitializeComponent is auto-generated.
What’s the difference between Move and LocationChanged? Resize and SizeChanged?
Both methods do the same, Move and Resize are the names adopted from VB to ease migration to C#.
With these events, why wouldn’t Microsoft combine Invalidate and Paint, so that you wouldn’t have
to tell it to repaint, and then to force it to repaint?
Painting is the slowest thing the OS does, so usually telling it to repaint, but not forcing it allows for the
process to take place in the background.
Before in my VB app I would just load the icons from DLL. How can I load the icons provided by .NET
dynamically?
By using System.Drawing.SystemIcons class, for example System.Drawing.SystemIcons.Warning
produces an Icon with a warning sign in it.
When displaying fonts, what’s the difference between pixels, points and ems?
A pixel is the lowest-resolution dot the computer monitor supports. Its size depends on user’s settings
and monitor size. A point is always 1/72 of an inch. An em is the number of pixels that it takes to display
the letter M.
| 0 Comments |
Variables that have only one copy per class are known as static variables. They are not attached to a
particular instance of a class but rather belong to a class as a whole. They are declared by using the
static keyword as a modifier. For example:
where, the name of the variable is varIdentifier and its data type is specified by type.
Static variables that are not explicitly initialized in the code are automatically initialized with a default
value. The default value depends on the data type of the variables. The table given below shows the
default values:
boolean false
byte 0
short 0
int 0
long 0L
char ‘u0000′
float 0.0F
double 0.0D
Interrupt latency is the time between the generation of an interrupt by a device and the servicing of the
device which generated the interrupt. For many operating systems, devices are serviced as soon as the
device’s interrupt handler is executed. Interrupt latency may be affected by interrupt controllers,
interrupt masking, and the operating system’s (OS) interrupt handling methods.
A null pointer has a reserved value, often but not necessarily the value zero, indicating that it refers to
no object. Null pointers are used routinely, particularly in C and C++ where the compile-time constant
NULL is used, to represent conditions such as the lack of a successor to the last element of a linked list,
while maintaining a consistent structure for the list nodes.
A special pointer type called the “void pointer” points to an object of unspecified type and cannot be
dereferenced. The address can be directly manipulated by casting a pointer to and from an integral type
of sufficient size.
9. What is ISR?
Integrated Services Routers (ISRs) are Cisco router product series that integrates many functions into a
single device. An example of such devices is a device that acts as both router and switch, and provides
other functions as well.
Void
No we cannot use printf() in ISR because ISRs’ are a part of kernel and kernel is not linked with libaray
provided by C,so when we use printf() in ISR it should generate a linkage error.
CISC is designed in mind that if a procedure being designed into the CPU it would be faster compare to if
it was written as software code.
A real-time operating system (RTOS) is an operating system that guarantees a certain capability within a
specified time constraint. For example, an operating system might be designed to ensure that a certain
object was available for a robot on an assembly line. In what is usually called a “hard” real-time
operating system, if the calculation could not be performed for making the object available at the
designated time, the operating system would terminate with a failure. In a “soft” real-time operating
system, the assembly line would continue to function but the production output might be lower as
objects failed to appear at their designated time, causing the robot to be temporarily unproductive.
Some real-time operating systems are created for a special application and others are more general
purpose. Some existing general purpose operating systems claim to be a real-time operating systems. To
some extent, almost any general purpose operating system such as Microsoft’s Windows 2000 or IBM’s
OS/390 can be evaluated for its real-time operating system qualities. That is, even if an operating system
doesn’t qualify, it may have characteristics that enable it to be considered as a solution to a particular
real-time application problem.
* multitasking
* Process threads that can be prioritized
* A sufficient number of interrupt levels
Real-time operating systems are often required in small embedded operating systems that are packaged
as part of micro devices. Some kernels can be considered to meet the requirements of a real-time
operating system. However, since other components, such as device drivers, are also usually needed for
a particular solution, a real-time operating system is usually larger than just the kernel.
18. What is the difference between hard real-time and soft real-time OS?
A hard real time system guarantees that critical tasks complete on time this goal requires that all delays
in the system be bounded from the retrieval of the stored data to the time that it takes the o.s to finish
any request made of it.
A soft real time system where a critical real time task gets priority over other tasks and retains that
priority until it completes.As in hard real time system kernel delays need to be bounded.
Priority inversion is a situation where in lower priority tasks will run blocking higher priority tasks waiting
for resource (mutex). For ex: consider 3 tasks. A, B and C, A being highest priority task and C is lowest.
Look at sequence of context swaps
Priority inheritance is a method for eliminating priority inversion problems. Using this programming
method, a process scheduling algorithm will increase the priority of a process to the maximum priority
of any process waiting for any resource on which the process has a resource lock.
The basic idea of the priority inheritance protocol is that when a job blocks one or more high priority
jobs, it ignores its original priority assignment and executes its critical section at the highest priority level
of all the jobs it blocks. After executing its critical section, the job returns to its original priority level.
22. How many types of IPC mechanism you know?
Local
Local IPC is for communication among process on a single machine. Local IPC is useful for data sharing,
signaling, and synchronization.
Mutexes, semaphores, and events can be named, or unnamed (identified by handle) and can be
protected by NT permissions.
Atoms
Atoms are globally available strings or integer values identified by a handle. Atoms were typically used
for DDE. The global atom table is also limited to 37 strings total. I do not recommend the use of atoms as
they seem to be outdated. Instead, other more up to date IPC mechanisms should be used.
Shared Memory
Shared memory is a block o f memory which multiple processes can access. Under Win16 all memory
was accessible by any process so pointers could be just passed between processes. Win32 has memory
protection mechanisms, and a processes memory is virtually mapped to that process. Win32 however
can map a block of memory into multiple processes virtual memory spaces. Even though the shared
block of memory may appear to be at different locations to each process, each will point to the same
physical location in memory. In addition, this mechanism allows you to control which processes have
access to shared memory blocks. Win32 can also map a disk file into virtual memory. Because of this,
when shared memory is used, it is called a memory mapped file.
Win32 also does this to the code segment of executables. When multiple instances of an executable are
loaded, only one copy of the code is loaded into physical memory, while it is mapped into multiple
virtual spaces.
Mutexes
A mutex (Mutual Exclusion) is an object which can be owned, but only owned by a single thread at a
time. Any other thread trying to gain ownership, will be blocked and queued in order of requests.
Mutexes are used to control exclusive access to any global object, or non reentrant code. Mutexes can
be used to control access to shared memory, hardware, or other single access items.
Semaphores
A semaphore is like a mutex, except that a specified number of threads can own a specific semaphore at
one time. When the semaphore is created, this number is specified. Semaphores are typically used to
limit access to resources. An example of this might be to prevent “thrashing” of a resource by setting the
maximum number of threads which can concurrently access the object.
Critical Sections
Critical sections are similar to mutexes, however mutexes differ from critical sections in that they can be
accessed across processes and threads, while a critical section, can only be access across threads from
within the same process. Critical sections are also lighter weight, cannot be named, or have security
attributes assigned to them.
Events
An event is an object which threads can wait for to be triggered. Any free thread may then trigger the
event, which will then release the other waiting threads. An event can be used to hold threads from
accessing something that has not been initialized or ready yet. They can also be used to signal that input
is available, or a device is ready to accept more data.
Messages
Messages can be used to send a one way queued instructions/status to a single thread. You can send
messages to an existing windows message queue, and filter them as they come in, or create your own
queue within a secondary thread. Messages are good for non time critical communications, or to
serialize handling. Messages can contain only a limited amount of data however. Each message can
contain only one 16 bit integer, and one 32 bit integer. When communicating between threads, pointers
may be passed in the 32 bit parameter. However when communicating between processes pointers may
not be passed, even when the pointer identifies shared memory as each process may see the shared
memory at a different location in it s virtual space. Object handles (Mutexes, semaphores, events)
cannot be passed in the message data, however such handles can be duplicated, and the duplicated
handles may be passed via the message data. (See DuplicateHandle)
DDE
DDE (Dynamic Data Exchange) was the common way to externally control applications in the 16 bit
world. DDE is still used occasionally, however it has been strategically replaced by COM. You should use
Com instead of DDE, unless the application you need to communicate with only understands DDE. DDE
also tends to be slow, and the built in DDE in Delphi/C++ Builder is “less than perfect”.
Clipboard
The clipboard can also be used for IPC, however in most situations it is not advisable as it is a global
resource.
OLE/Com
OLE (Object Linking & Embedding) has evolved into COM (Component Object Model). COM allows you
to do many things. With COM you can create language independent objects, expose interfaces from
applications to allow external control, and much more. COM allows you to expose interfaces. An
interface is a defined set of methods and properties which allow you to proxy calls to any code or object
that you wish. An interface is like a contract. Any time that the interface is implemented, all of it s
members must be implemented.
Network
Network IPC is for communication between processes on different machines.
Network Protocols
Network protocols allow you the most flexibility, however they bind you to a single protocol, and
require a lot of extra programming. Most times you do not need this flexibility and it is better to use a
higher level protocol. Network protocols are also lighter weight.
Some common protocols used for network communication are IPX/SPX (Novell), NetBEUI (Microsoft),
and TCP/IP (Internet).
NetBios is also a protocol, but it is a slightly higher protocol than the others. It abstracts some of the
features of the other network protocols while still providing you with most of their advantages. NetBios
s main feature is that is does not bin you to a particular protocol which your network configuration
and/or hardware may dictate. NetBios commonly runs on top of NetBEUI or TCP/IP.
If you do decide you need to work at the network protocol level, TCP/IP is probably your best bet. It is
very flexible, in widespread use (The internet runs on it), works with any operating system, has tons of
existing services, and has become the de facto standard.
Mailslots
Mailslots are like messages except that they can be sent across a network. Mailslots also differ from
messages in that they are not arbitrarily limited in the amount of data they can contain, and mailslots
can be broadcast to a group of receivers. Mailslots however are sent as datagrams, and therefore are
not guaranteed to arrive at their destination. Mailslots are similar to TCP/IP s UDP mechanism, but at a
slightly higher level. If delivery must be guaranteed, another method should be used.
Pipes
A pipe is a communication channel with two endpoints. Pipes are similar to TCP connections. Pipes
however can be optionally named, and contain security attributes. Pipes can also be one or two way.
Pipes are used both for network communication, and locally. For example, the console is a pipe. If you
want to open a DOS session / command window, you can swap a pipe for it s standard in and standard
out, thus giving your application full control of the window.
RPC
RPC (Remote Procedure Calls) allow you to make function/procedure calls in which the code actually
executes on another system. RPCs are typically used with older systems, mainframes, or for
implementing distributed object systems.
Distributed Objects
Distributed objects are used for communication among objects. These objects can be local or remote.
This easily allows you to distribute your programs with complete abstraction of location. The two most
common distributed object standards are DCom and Corba.
Without distributed object systems, developers need to implement their own protocols and also decide
upon and program for a network transport. In many cases they also tie their protocol to a specific
language, and even a platform. Distributed object systems abstract the user from all this and provide a
high level interface which is platform independent, language independent, and network protocol
independent.
DCom
DCom is just a distributed version of COM (Component Object Model). DCom is controlled by Microsoft
and therefore is tied heavily to Win32 and other Microsoft technologies. The specification is available for
other platforms, but is rarely used. For all intents and purposes, DCom is for WinTel only. DCom is also
heavily tied to NT security. If you have lots of users that do not have NT accounts, this may pose a major
headache for you. NT security can be bypassed by using the Midas socket server (I ve been told you do
not need a Midas license to merely use this single component).
Corba
Corba (Common Object Request Broker Architecture) is a platform independent distributed object
protocol. Corba is also implemented by many vendors including Inprise/Visigenic. This allows you to
choose your implementation. The Corba standard is controlled by the OMG (Object Management
Group).
In simple terms a Semaphore is a unit or resource which is used for synchronization between two
processes , it is kind of flag (in abstract terms) which every process will check before processing ahead to
avoid the deadlock situation
A spin lock is a lock where the thread simply waits in a loop (”spins”) repeatedly checking until the lock
becomes available. As the thread remains active but isn’t performing a useful task, the use of such a lock
is a kind of busy waiting. Once acquired, spin locks will usually be held until they are explicitly released,
although in some implementations they may be automatically released if the thread blocks, or “goes to
sleep”.
Virtual memory is a common part of most operating systems on desktop computers. It has become so
common because it provides a big benefit for users at a very low cost.
Most computers today have something like 64 or 128 megabytes of RAM (random-access memory)
available for use by the CPU (central processing unit). Often, that amount of RAM is not enough to run
all of the programs that most users expect to run at once. For example, if you load the Windows
operating system, an e-mail program, a Web browser and word processor into RAM simultaneously, 64
megabytes is not enough to hold it all. If there were no such thing as virtual memory, your computer
would have to say, “Sorry, you cannot load any more applications. Please close an application to load a
new one.” With virtual memory, the computer can look for areas of RAM that have not been used
recently and copy them onto the hard disk. This frees up space in RAM to load the new application.
Because it does this automatically, you don’t even know it is happening, and it makes your computer
feel like is has unlimited RAM space even though it has only 32 megabytes installed. Because hard-disk
space is so much cheaper than RAM chips, virtual memory also provides a nice economic benefit.
The area of the hard disk that stores the RAM image is called a page file. It holds pages of RAM on the
hard disk, and the operating system moves data back and forth between the page file and RAM. (On a
Windows machine, page files have a .SWP extension.)
Of course, the read/write speed of a hard drive is much slower than RAM, and the technology of a hard
drive is not geared toward accessing small pieces of data at a time. If your system has to rely too heavily
on virtual memory, you will notice a significant performance drop. The key is to have enough RAM to
handle everything you tend to work on simultaneously. Then, the only time you “feel” the slowness of
virtual memory is in the slight pause that occurs when you change tasks. When you have enough RAM
for your needs, virtual memory works beautifully. When you don’t, the operating system has to
constantly swap information back and forth between RAM and the hard disk. This is called thrashing,
and it can make your computer feel incredibly slow.
Yes structures can be passed to functions by value. Though it has two disadvatanges :
When a array is passed to a function, the array is internally changed to a ‘pointer’. And pointers are
always passed by reference.
A macro is a constant that provides straight textual substitution where used, while an inline function is a
procedure that is actually called each time. Macros do have a few advantages over inline functions, but
the disadvantages are numerous. For example, type checking and argument validation is not performed
in a macro, while they are in functions for the most part.
It is a matter that everyone should decide for themselves, but Bjarne Stroustrup, who created C++,
advocates the use of inline functions over macros.
Inline functions are an imperative feature of C++ and are frequently used with classes. These are no
different from the normal functions except for the fact that they are never actually called. These
functions are, as their name suggests, expanded in line at each point of invocation. All that needs to be
done to enable or cause a function to expand at the point of invocation is to add the inline keyword
before the function definition.
An inline function replaces the call to the function by the body of the function, thus reducing the
overhead of saving the context in stack. This is good for functions which are small in size and called
occasionally. A recursive function calls an instance of it and thus can be a deeply nested. In this case if
we define the recursive function as inline, it would replace every call to itself with the body of function
and thus eating up a lot of code space.
32. #define cat(x,y) x##y concatenates x to y. But cat(cat(1,2),3) does not expand but gives
preprocessor warning. Why?
Or
in this case the cat(x,y) is the macro which is defined by using the preprocessor directive , this will be
substituted only at the place where it is called in this example it happens like this
33. Can you have constant volatile variable? Yes, you can have a volatile pointer?
You can have a constant pointer to a volatile variable but not a constant volatile variable.
Or
Or
It is possible to have “const volatile” declaration. This indicates that the variable defined like this is not
possible to change within that context. It can be changed by an external event. const declaraion just says
that it will be readonly within the context, that area can be modified by an interrupt routine or another
process.
35. Operations involving unsigned and signed — unsigned will be converted to signed
39. Which way of writing infinite loops is more efficient than others?
40. Who to know whether system uses big endian or little endian format and how to convert among
them?
41. What are forward reference w.r.t. pointers in c?
42. How is generic list manipulation function written which accepts elements of any kind?
43. What is the difference between embedded systems and the system in which RTOS is running?
44. How can you define a structure with bit field members?
struct abc {
unsigned int a:1;
unisgned int b:2;
};