Beruflich Dokumente
Kultur Dokumente
http://www.makelinux.net/kernel_map/
Linux kernel map
Page fault
What is a page fault?
If the process is accessing a virtual memory location that is not mapped by
the page table, a page fault will occur. Page faults could mean either that the
process has tried to access memory that it should not have access to, or that
part of the application's memory has been swapped out. In the last case, the
page will be swapped back in and execution will proceed where it was
interrupted
Boot sequence
Boot loader/Boot strap loader/BIOS is a small program present in
ROM.When a computer or any embedded system boots up, the first
program/software that gets executed is the boot loader.The boot loader's
address is mapped in hardware to a ROM chip.
The boot loader typically will have less instructions and its main purpose is
to access non volatile or other memory to start and load the operating
system or any other program which the system is designed for.
The Power On Self Test, or POST routine runs to find certain hardware and to
test that the hardware is working at a basic level.
- Hardware devices are initialized. PCI devices need to be given IRQs,
input/output addresses and a table of these devices is then displayed onscreen.
The BIOS must search for an operating system on the various media that is
supported. This usually occurs by searching for a boot sector on the devices
that are specified in the CMOS.
- Once a valid boot sector has been found, it is copied into RAM and then
executed.
Boot sector
A sector has a length of 512 bytes. A sector becomes a "boot" sector
because of it's location and the hex value 0xaa55 in the final two bytes. The
BIOS looks for this value when scanning potential boot media. When one
- It is technique for the exchange of data among two or more threads in one
or more processes. IPC techniques are semaphores,mutex, shared memory,
signals, message passing, pipes, sockets and rpc calls.
Binary semaphore
The simplest kind of semaphore is the "binary semaphore", used to control
access to a single resource, which is essentially the same as a mutex. A
binary semaphore is always initialized with the value 1. When the resource is
in use, the accessing thread calls P(S) to decrease this value to 0, and
restores it to 1 with the V operation when the resource is ready to be freed.
The value of the semaphore is initialized to the number of equivalent shared
resources it is implemented to control. In the special case where there is a
single equivalent shared resource, the semaphore is called a binary
semaphore. The general case semaphore is often called a counting
semaphore.
When a signal is sent to a process, the operating system interrupts the
processes' normal flow of execution. If the process has previously registered
a signal handler, that routine is executed.Otherwise the default signal
handler is executed.
Message passing - Communication is made by the sending of messages to
recipients. Forms of messages include function invocation, signals, and data
packets.
{
int i=2;
int j=3;
if(&i > &j) printf("stack grown downwards");
else printf("stack grows upwards");
}
define 2 local variables one after other and try to print the address
11. why do we require semaphore?
For process synchronization, it is a mechanism to invoke the sleeping
process to become ready for execution. Its mechanism where a process can
wait for resources to be available.typical example is producer consumer
process. The producer process creates resources and signals the semaphore
saying resource is available. Consumer process waiting on the semaphore
gets the signal that resource is available.
12. write a small piece of code protecting a shared memory variable
with a semaphore?
int global_i;
void increment_shared_memory {
wait(semaphore);
global_i++;
signal(semaphore);
}
13. what are the different types of semaphores and where they are
used?
Binary semaphore and counting semaphore. Binary semaphore is same as
mutex. Binary semaphore tries to protect only one resource.
heap segment
- The segment of memory which is used for dynamic memory allocation is
known as heap. It is the responsibility of the programmer to deallocate it
after its use. Or alternatively it will be garbage collected by the OS.
17. what is OS scheduling mechanism in our OSE?
18. how and wher the context related information is stored PCB i guess
19. what is a make command and what are al its uses?
20. what if no process responding how it is handled (watch dog timeout
mechanism)
21. what is an ELF
- Executable and Linking Format is a common standard file format for
executables, object code, shared libraries, and core dumps.
22. what is priority inversion?
- In a scenario where a low priority task holds a shared resource (example
semaphore) that is required by a high priority task. This causes the
execution of the high priority task to be blocked until the low priority task
has released the resource. This scenario is averted by the OS by increasing
the priority of the low-proi process until it completes the task and releases
the resources.
23. Locality of reference:
It deals with a process accessing a resource multiple times.
There are three type of localities namely
temporal - A resource is referenced at point in time and will be referenced
again in near future.
spatial - The concept that the likelihood of referencing a resource is higher if
a resource near it has been referenced.
sequencial - The concept of accessing the memory sequentially.
Compilation process
- In the first stage C source code is compiled and assembly code (.s) is
generated, in the second stage the assembly code is converted into object
code (.o) which is machine understandable. In third stage the linking will
occur wherein the object code in linked to code libraries. In this stage the
executable is generated.
make and makefile
- see tutorial http://www.eng.hawaii.edu/Tutor/Make/index.html
CC
CFLAGS
Special options which are added to the built-in C rule. (See next page.)
$@
$?
RTOSs allow fast and efficient context switching with very less
overhead.
Thread pooling
Thread pool is a collection of managed threads usually organized in
a queue, which execute the tasks in the task queue.
Creating a new thread object every time you need something to be
executed asynchronously is expensive. In a thread pool you would
just add the tasks you wish to be executed asynchronously to the
task queue and the thread pool takes care of assigning an available
thread, if any, for the corresponding task. As soon as the task is
completed, the the now available thread requests another task
(assuming there is any left).
Different types of memory fragmentation
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 reentrant 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
thread which has acquire the lock can only release it.
whereas in semaphore any other thread or process can release the
semaphore taken by a process/thread
2. If a process locking the semaphore is killed by any chance and another
process waiting for the lock to be released, never gets notified.
Whereas in mutex, if another process is waiting for the lock, and the process
acquired mutex got killed, the kernel informs
3. recursion is not possible with semaphore, meaning locking the same
semaphore again by the same process will lead to deadlock condition.
but mutex recursion can be enabled. By which the same process can acquire
the mutex lock any number of times
4.semaphore doesnt support priority inheritance, so shouldn't be preferred
for RTOS
http://see.stanford.edu/materials/icsppcs107/23-Concurrency-Examples.pdf
Race conditions arise in software when separate processes or threads of
execution depend on some shared state. Operations upon shared states are
critical sections that must be mutually exclusive in order to avoid harmful
collision between processes or threads that share those states.
Here is a simple example:
Let us assume that two threads T1 and T2 each want to increment the value
of a global integer by one. Ideally, the following sequence of operations
would take place:
1. Integer i = 0; (memory)
2. T1 reads the value of i from memory into register1: 0
3. T1 increments the value of i in register1: (register1 contents) + 1 = 1
4. T1 stores the value of register1 in memory: 1
5. T2 reads the value of i from memory into register2: 1
6. T2 increments the value of i in register2: (register2 contents) + 1 = 2
7. T2 stores the value of register2 in memory: 2
8. Integer i = 2; (memory)
Since all threads run in the same address space, they all have access to the
same data and
variables. If two threads simultaneously attempt to update a global counter
variable, it
is possible for their operations to interleave in such way that the global state
is not
correctly modified. Although such a case may only arise only one time out of
thousands, a concurrent program needs to coordinate the activities of
multiple threads
using something more reliable that just depending on the fact that such
interference is
rare. The semaphore is designed for just this purpose.
A semaphore is somewhat like an integer variable, but is special in that its
operations
(increment and decrement) are guaranteed to be atomicyou cannot be
halfway
through incrementing the semaphore and be interrupted and waylaid by
another thread
trying to do the same thing. That means you can increment and decrement
the
semaphore from multiple threads without interference. By convention, when
a
semaphore is zero it is "locked" or "in use". Otherwise, positive values
indicate that the
semaphore is available. A semaphore will never have a negative value.
Deadlock