Sunteți pe pagina 1din 8

Union:

Unions like structure contain members whose individual data types may differ from one another. However the
members that compose a union all share the same storage area within the computers memory where as each
member within a structure is assigned its own unique storage area. Thus unions are used to conserve memory.
They are useful for application involving multiple members. Where values need not be assigned to all the
members at any one time. Like structures union can be declared using the keyword union as follows:

union item
{
int m;
float p;
char c;
}
code;

this declares a variable code of type union item. The union contains three members each with a different data
type. However we can use only one of them at a time. This is because if only one location is allocated for union
variable irrespective of size. The compiler allocates a piece of storage that is large enough to access a union
member we can use the same syntax that we use to access structure members. That is

code.m
code.p
code.c

are all valid member variables. During accessing we should make sure that we are accessing the member whose
value is currently stored.
For example a statement such as

code.m=456;
code.p=456.78;
printf(%d,code.m);
That mean code.m will read the first 2 byte from code.p

Big and little endian

In a big-endian system, the most significant value in the sequence is stored at the lowest storage address (i.e.,
first).
In a little-endian system, the least significant value in the sequence is stored first.
For example, consider the number 1025 (2 to the tenth power plus one) stored in a 4-byte integer:
00000000 00000000 00000100 00000001
Address
Big-Endian representation of 1025
Little-Endian representation of 102500
00000001 byte 1
00000100 byte2
00000000 3
00000000 4 most significant
big --> a5r byte fy 22l adderss
litt: el 3ks

Process
Process is a naturally occurring or designed sequence of operations or events, possibly taking up time, space,
expertise or other resource, which produces some outcome. A process may be identified by the changes it
creates in the properties of one or more objects under its influence

Thread
Threads are similar to processes, in that both represent a single sequence of instructions executed in parallel
with other sequences, either by time slicing or multiprocessing. Threads are a way for a program to split itself
into two or more simultaneously running tasks

Task
a set of program instructions is loaded in memory

Process VS. Thread


A process is an executing instance of an application. For example, when you double-click the
Microsoft Word icon, you start a process that runs Word. A thread is a path of execution within a
process. Also, a process can contain multiple threads. When you start Word, the operating system
creates a process and begins executing the primary thread of that process.
It's important to note that a thread can do anything a process can do. But since a process can consist
of multiple threads, a thread could be considered a 'lightweight' process. Thus, the essential difference
between a thread and a process is the work that each one is used to accomplish. Threads are used for
small tasks, whereas processes are used for more 'heavyweight' tasks - basically the execution of
applications.

Another difference between a thread and a process is that threads within the same process share the
same address space, whereas different processes do not. This allows threads to read from and write to
the same data structures and variables, and also facilitates communication between threads (whereas
communication between processes is a difficult proposition).
Also, context switching between threads is generally less expensive than in processes. And finally,
the overhead (the cost of communication) between threads is low relative to processes.

In more details

A single process can have multiple threads that share global data and address space with other
threads running in the same process, and therefore can operate on the same data set easily.
Processes do not share address space and a different mechanism must be used if they are to
share
data.
If we consider running a word processing program to be a process, then the auto-save and spell
check features that occur in the background are different threads of that process which are all
operating
on
the
same
data
set
(your
document).

process
In computing, a process is an instance of a computer program that is being
sequentially executed[1] by a computer system that has the ability to run several
computer
programs
concurrently.
Thread
A single process may contain several executable programs (threads) that work
together as a coherent whole. One thread might, for example, handle error signals,
another might send a message about the error to the user, while a third thread is
executing
the
actual
task
of
the...
------------------------------------------------------------------------------------------------------------------------------------------

Kernel
The central module of an operating system. It is the part of the operating system that loads first, and it remains
in main memory. Because it stays in memory, it is important for the kernel to be as small as possible while still
providing all the essential services required by other parts of the operating system and applications. Typically,
the kernel is responsible for memory management, process and task management, and disk management.
Typically, a kernel (or any comparable center of an operating system) includes an interrupt handler that handles
all requests or completed I/O operations that compete for the kernel's services, a scheduler that determines
which programs share the kernel's processing time in what order, and a supervisor that actually gives use of the
computer to each process when it is scheduled. A kernel may also include a manager of the operating system's
address spaces in memory or storage, sharing these among all components and other users of the kernel's
services. A kernel's services are requested by other parts of the operating system or by application programs
through a specified set of program interfaces sometimes known as system calls.

Mutex:
Is a key to a toilet. One person can have the key - occupy the toilet - at the time. When finished, the person
gives (frees) the key to the next person in the queue.
Officially: "Mutexes are typically used to serialise access to a section of re-entrant code that cannot be
executed concurrently by more than one thread. A mutex object only allows one thread into a controlled section,
forcing other threads which attempt to gain access to that section to wait until the first thread has exited from
that section."
Ref: Symbian Developer Library
(A mutex is really a semaphore with value 1.)

Semaphore:
Is the number of free identical toilet keys. Example, say we have four toilets with identical locks and keys. The
semaphore count - the count of keys - is set to 4 at beginning (all four toilets are free), then the count value is
decremented as people are coming in. If all toilets are full, ie. there are no free keys left, the semaphore count is
0. Now, when eq. one person leaves the toilet, semaphore is increased to 1 (one free key), and given to the next
person in the queue.
Officially: "A semaphore restricts the number of simultaneous users of a shared resource up to a maximum
number. Threads can request access to the resource (decrementing the semaphore), and can signal that they have
finished using the resource (incrementing the semaphore)."
Ref: Symbian Developer Library

-----------------------------------------------------------------------------------------

Mailbox follows the pull model. i.e. the sender task can send a message to the mailbox and the receiver doesn't
have to get it immediately. He has to check if there is a message in the mailbox to consume.
The difference depends on the OS implementation. Some OSes don't make any difference between pipe and
queue; some do it one way and some other ways. Here are a couple of them
1.
Queue can be shared between multiple tasks i.e. multiple tasks can consume from queue while pipe can be share
between two tasks only; one producer and the second consumer
2.
Message queue is same as pipe with the only difference that pipe is byte oriented while queue can be of any
size.

What is meant by cache memory?

Pipelining
(1) A

technique used in advanced microprocessors where the microprocessor begins executing a second instruction before
the first has been completed. That is, several instructions are in the pipelinesimultaneously, each at a different processing
stage.
The pipeline is divided into segments and each segment can execute its operation concurrently with the other segments.
When a segment completes an operation, it passes the result to the next segment in the pipeline and fetches the next
operation from the preceding segment. The final results of each instruction emerge at the end of the pipeline in rapid
succession.
Although formerly a feature only of high-performance and RISC -based microprocessors, pipelining is now common in
microprocessors used inpersonal computers. Intel's Pentium chip, for example, uses pipelining to execute as many as six
instructions simultaneously.
Pipelining is also called pipeline processing.
(2) A similar technique used in DRAM, in which the memory loads the requested memory contents into a
small cache composed of SRAM and then immediately begins fetching the next memory contents. This creates a twostage pipeline, where data is read from or written to SRAM in one stage, and data is read from or written to memory in the
other stage.
DRAM pipelining is usually combined with another performance technique called burst mode. The two techniques
together are called a pipeline burst cache.

Paging

)A

technique used by virtual memory operating systems to help ensure that the data you need is available as quickly as
possible. The operating systemcopies a certain number of pages from your storage device to main memory. When

a program needs a page that is not in main memory, the operating system copies the required page into memory and
copies another page back to the disk. One says that the operating system pages the data. Each time a page is needed that is
not currently in memory, a page fault occurs. An invalid page fault occurs when the address of the page being requested is
invalid. In this case, the application is usually aborted.
This type of virtual memory is called paged virtual memory. Another form of virtual memory is segmented virtual
memory.

// anonymous_structures.c
#include <stdio.h>
struct phone
{
int areacode;
long number;
};
struct person
{
char name[30];
char gender;
int age;
int weight;
struct phone; // Anonymous structure; no name needed
} Jim;
int main()
{
Jim.number = 1234567;
printf_s("%d\n", Jim.number);
}

S-ar putea să vă placă și