Gaurav Kumar Garg
BAN USER
Hello,
I am Gaurav Kumar Garg, a Young dynamic Embedded System Professional. I have Done Post Graduate Diploma in Embedded System & Design form CDAC Chennai, and B.Tech in Electronic and Communication from Rajasthan Technical University Kota. I am passionate about New Embedded Cutting Edge Technology. My Hobby are Swimming, Blog Writing, Programming, Playing Guitar.
ISR is not function .
ISR never accept or return any value !!!!!
Syntax-wise, strictly speaking you cannot pass an array by value in C.
void func (int* x); /* this is a pointer */
void func (int x[]); /* this is a pointer */
void func (int x[10]); /* this is a pointer */
by using stracture we can do it...
eg:
struct A { int arr[2]; };
void func(struct A);
Hear is the link for Complete understanding of boot sequence:
www(dot)geeksforembedded.blogspot.in/2013/12/linux-boot-process-how-computer-boots-up.html
In context Switch PC (Programme counter value store in stack), also value of CPSR(current programme Status Register) copy to SPSR(Saved programme Store Register).
- Gaurav Kumar Garg December 23, 2013Generally Padding use to alignment of bit data properlly.
hardware access data fast if it is properally align.
/* function to find no is power of 2 or not */
void find(int n)
{
if (n &(n-1))
printf ("Number is not power of 2\n");
else
printf ("Number is Power of 2\n");
}
Difference bw array and pointer is :
**Compiler allocate resource for array at compile time but compiler allocate resource for pointer at execution time.
** Array is a group of element but pointer point to the memory location of variable.
** Pointer are dynamic nature once memory are initialized it can be free or re-sized but for array once memory initialized it can not be free or re-sized.
Difference Between threads and processes
* Processes do not share their address space while threads executing under same process share the address space.
*From the above point its clear that processes execute independent of each other and the synchronization between processes is taken care by kernel only while on the other hand the thread synchronization has to be taken care by the process under which the threads are executing
*Context switching between threads is fast as compared to context switching between processes
*The interaction between two processes is achieved only through the standard inter process communication while threads executing under the same process can communicate easily as they share most of the resources like memory, text segment etc
****************************************************************************************
When a process executes a fork call, a new copy of the process is created with its
own variables and its own PID. This new process is scheduled independently, and (in general) executes almost independently of the process that created it. When we create a new thread in a process, in contrast, the new thread of execution gets its own stack (and hence local variables) but shares global variables, file descriptors, signal handlers, and its current directory state with the process that created it.
************************************************************************************************
/* compile and execute this programme on linux plateform gcc programme_name -l pthread */
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <stdlib.h>
int count =0;
int flag1=0;
void *fun1(void *);
void *fun2(void *);
int main()
{
pthread_t id1,id2;
pthread_create (&id1,NULL,&fun1,NULL);
pthread_create (&id2,NULL,&fun2,NULL);
pthread_join(id1,NULL);
pthread_join(id2,NULL);
return 0;
}
void *fun1(void *p)
{
for(;count<10;)
{
if(flag1 ==0)
{
printf ("%d ",count++);
flag1=1;
}
}
}
void *fun2(void *p)
{
for(;count<10;)
{
if(flag1 ==1)
{
printf ("%d ",count++);
flag1=0;
}
}
}
/*end of programme*/
/* Compile and Executed this code in Linux GCC 3.2*/
#include <stdio.h>
int count(int n)
{
int i=0;
if(n==0)
return 0;
else
{
while (n>0)
{
if(n&1)
++i;
n>>=1;
}
return i;
}
}
int main()
{
int n;
printf ("Enter no\n");
scanf ("%d",&n);
printf ("no of bit that are 1 one in this number is %d\n",count(n));
return 0;
}
@ joy.vivin
- Gaurav Kumar Garg December 23, 2013linking:
there are 4 stage when you compile and execute your programme...
1. preprocessing gcc -E your_file_name.c -o final.i
2. Compiling gcc -S final.i -o final.s
3. Assembling gcc -c final.s -o final.o
4. linking gcc -o final.o final
when you write printf function in c programme . at preprossing stage it is replace by actual function calling parameter. it does not know where the defination of printf function is. but at the time of linking it provide information of defination of printf.
if you are using static linking then it will include printf function defination along with executable. if you are using dynamic linking then it will include some information about where to find defination of printf function when you will ececute this programme in anothe machine.
@> let me know if i am wrong.....