Browsing all articles from January, 2012
Jan
31

Whether should i use processes or threads in Linux?

While designing any system usually we might confuse between thread and process usage . We think should we use thread or process for our requirement. Which will be the best choice.?

 

So Here are some guidelines to help you……

 

 

  • All threads inside a program always run from the same executable binary. Where a child process , may run a from different executable binary by calling an exec function.
  • If one process crashes or has a buffer overrun, it does not affect any other process at all, whereas if a thread crashes, it takes down all of the other threads in the process because threads share the same virtual memory space and other resources. read more
Jan
30

Convert file descriptor to file pointer | Convert file pointer to file descriptor in Linux by C programming

 If you all ready know the difference between file descriptor and file pointer then good otherwise please read this post

Whats is difference between file descriptor and file pointer?

 

 

File descriptor to file pointer :

for converting file descriptor to file pointer in linux fdopen() function is used

#include <stdio.h
FILE *fdopen(int fildes, const char *mode);

fildes is file descriptor

mode is the character value which indicate the mode of file operation (same as we use in fopen() function)

Example :

#include <stdio .h>
#include <fcntl .h>
 
int main(){
int fd;
FILE *fp;
fd = open("shareprogrammingtips.txt",O_WRONLY | O_CREAT | O_TRUNC);
if(fd<0)
{
   printf("open call fail");
   return -1;
}
 
fp=fdopen(fd,"w");
fprintf(fp,"we got file pointer fp bu using File descriptor fd");
fclose(fp);
close(fd);
return 0;
}
</fcntl></stdio>

read more

Jan
28

Confusion with megabytes, 1 megabyte is 1 million bytes or 1024 * 1024 (1048576) bytes?

i have two question

1> 1 megabyte is 1 million bytes or 1024 * 1024 (1048576) bytes?  

2> what is the Difference between Mibit/s or Mib/s and MB/s or MBps and Mbit/s, Mb/s and Mbps MiB/s or MiBps?

“MB/s” usually means “megabytes per second”. This can be one of two definitions, depending on who you ask:

1> 1 million bytes per second (8 million bits per second) (per the IEEE’s definition)

OR

  • 2> The more commonly seen definition of 1024 * 1024 (1048576) bytes per second (8388608        bits per second), seen commonly in many usages.

 

In most of the way 1 megabyte = 1024 * 1024 (1048576) bytes were taken in account but few years ago

The IEEE has proposed that computers should follow the SI prefixes, and use “Megabyte” to mean 10^6 bytes, not 2^20 bytes, which has been done historically. And thus created all the confusion over which definition of a megabyte one is actually using.

read more

Jan
28

Why variables can not be declared in a switch statement just after labels?

see this code

#include&lt;stdio.h&gt;
int main()
{
   int i=1;
   switch(i)
   {
       case 1: int x=10;
               printf(" x is %d",x);
       break;
    }
    return 0;
}

Do you think this code will compile? if yes then you need to read this post….

read more

Jan
7

Structure of a C-Program in Memory | How Heap,Stack,Data and Code segments are stored in memory?

Author JIGAR PATEL    Category c, Tips     Tags

This is most confusing question for and beginner of c programming language.  They dont know the all segment name and dont know on which segment which data are going to store . So here i am just giving you the brief idea about the structure of any c program in memory.  

This structure can be divided in 3  parts .

  • Data Segment
    • Initialized data segment (initialized to explicit initializers by programmers)
    • Uninitialized data segment (initialized to zero data segment – BSS [Block Start with Symbol])
  • Code Segment
  • Stack and Heap areas

read more

Jan
5

How can i detect Windows or Linux in C,C++ programming?

 

Sometimes we need to write platform independent  code which works in windows and linux machine without giving any flag or any modification in code or make file manually.

So in such case i usually use compiler generated macro to check the platform .

 

In Linux all c and c++ compiler define macro like  linux, In Windows all c and c++ compiler define macro like _WIN32 

so we can use this macro to separate code for linux and windows see belows example code

read more

Jan
5

How can I get what my main function has returned in Linux?

 

In a C program if we want to give some input from terminal then we can give it by:

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

In the same way, if we want to get return value of main() function then how can we get it?

 

In each main() we write return 1 or return 0; how can we know what my main() has returned at terminal?

read more

Jan
4

Full Specifications of Leaked Samsung Galaxy S3

Author saurabh    Category Uncategorized     Tags

Samsung is planning to launch 3D Android smartphones next year. Company is actively working on the next generation of 3D technology to integrate in these smartphones, they won’t just provide 3D display, but will also help you play 3D games, record 3D movies and work with 3D TVs.

Apart from these new 3D devices, Samsung might also include the technology in Galaxy S III. According to ETnews, it is however not final till now whether Galaxy S3 will come with 3D or not, but in order to procure 3D components at a major level, Samsung would need six months and that would delay the S3 launch. Thus Galaxy S 3D (tentative name) might be company’s first 3D Android phone, which is expected to launch in Q2, 2012.

Korean publication further stated that Galaxy S III announcement is currently scheduled for Mobile World Congress with availability in April. S3 is expected to feature a quad core processor; but there is no word on other specifications, which we suspect would include Android 4.0 and at least 4.5 inch display.

 

Highlight Features of Samsung Galaxy S3:

  • NFC Chip,
  • 3rd generation Super AMOLED 3D Screen,
  • Ultra Low SAR Levels,
  • Blazing fast Speeds with Quad Core Processor,
  • Probable 4G Supported Phone,
  • Slimmest Smart Phone ever

 

Full Specifications of Samsung Galaxy S3:

read more

Follow us on Twitter! Follow us on Twitter!

Search in this website

our sponsors

latest comments

Find us on Facebook

Top Authors

35 posts
saurabh
22 posts
10 posts

Find us on stackoverflow

Polls

Tell us who you are

View Results

Loading ... Loading ...

My Bookmarks

Sponsers Link