User Profile

Collapse

Profile Sidebar

Collapse
ajaygargnsit
ajaygargnsit
Last Activity: Jul 20 '07, 03:26 PM
Joined: Jul 10 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • ajaygargnsit
    started a topic A question on threading in Linux

    A question on threading in Linux

    I just want to "confirm" some of the latest multithreading models in Linux and Solaris.

    1. In the latest versions of Linux (Fedora etc.) the multithreading model used is
    1:1 (that is 1 kernel thread for each user thread..)

    2. Does Linux uses preemption for all threads. If the answer is yes, is there
    way to implement "voluntaril y leaving of CPU" by a Linux thread.
    ...
    See more | Go to post

  • ajaygargnsit
    started a topic Another bitwise operators puzzle
    in C

    Another bitwise operators puzzle

    Given a number, we need to divide it by 3, without using *, /, % operators. Well the question also mentions that itoa() function is available !!
    See more | Go to post

  • ajaygargnsit
    replied to Multiples using bitwise shift
    in C
    Thanks Revenspoint

    But I think, we can do this, even without using '+' operator. Consider this :

    // Assume int to be two bytes

    unsigned int next_of_eight(u nsigned int num)
    {
    unsigned int mask = 0xfff8;

    // 1. Truncate 'num' to the highest multiple of 8, less than or equal to num

    num = num & mask;

    // 2. Now move towards...
    See more | Go to post

    Leave a comment:


  • ajaygargnsit
    replied to Multiples using bitwise shift
    in C
    Thanks Revenspoint

    But I think, we can do this, even without using '+' operator. Consider this :

    // Assume int to be two bytes

    unsigned int next_of_eight(u nsigned int num)
    {
    unsifned int mask = 0xfff8;

    // 1. Truncate 'num' to the highest multiple of 8, less than or equal to num

    num = num & mask;

    // 2. Now move towards...
    See more | Go to post

    Leave a comment:


  • ajaygargnsit
    replied to Multiples using bitwise shift
    in C
    @Sicarie

    Well .. I don't get you Sir. Its more of a doubt of algo, not the implementation ...
    See more | Go to post

    Leave a comment:


  • ajaygargnsit
    started a topic Multiples using bitwise shift
    in C

    Multiples using bitwise shift

    I came across this question ::

    Given a positive number, determine the next multiple of 8, using only bitwise operators.
    Eg. if number is 13, the answer shhud be 16;
    if number is 41, answer shud be 48, and so on

    Kindly somebody help.
    See more | Go to post

  • ajaygargnsit
    replied to what does shifting "negative" times mean ?
    in C
    Thanks for clarifying.
    See more | Go to post

    Leave a comment:


  • ajaygargnsit
    started a topic what does shifting "negative" times mean ?
    in C

    what does shifting "negative" times mean ?

    I use a Turbo C compiler, and the value i get for say, 32<<-1 is 0. In fact this is the case for any integer I take.

    Kindly somebody help what's happening ... ?
    Moreover, is there any difference if I try this with gcc. ( i don't have it currently .. :(
    See more | Go to post

  • ajaygargnsit
    replied to Doubt on compiler-processor relationship
    in C
    Ahh ... Well, it would be nice if I could get the "complete" procedure as to what happens, from the step of writing a C program, to the step of getting it executed ..

    I will be obliged to get help.

    (Well, wouldn't be nice if we start one step at a time, and then discuss each step, taking into account the different cases possible at each step..)
    See more | Go to post

    Leave a comment:


  • ajaygargnsit
    replied to Doubt on compiler-processor relationship
    in C
    Ok, I think that now I can make sense ... Taking my system configuration example (Fedora, gcc, Intel pentium 4), the steps that happen are as follows ::

    During installation, the initial booting stage checks for the processor. Now since mine is Intel P4, it will load every binary (including gcc of course), targetted towards P4.

    Now the gcc binaries include ::

    a) The front end binaries (written for P4)...
    See more | Go to post

    Leave a comment:


  • ajaygargnsit
    replied to Doubt on compiler-processor relationship
    in C
    Well JosAh, I moved this here, so we can continue in the same thread ...

    Ok.. so that means, that in the installation CDs of Linux, we have different binaries of gcc, one each for all the processors possible?...
    See more | Go to post

    Leave a comment:


  • ajaygargnsit
    replied to Doubt on compiler-processor relationship
    in C
    That means, that compilation from source code to object code is a two step process :: one at the front end side, other at the back end side, right ?...
    See more | Go to post

    Leave a comment:


  • ajaygargnsit
    started a topic Doubt on compiler-processor relationship
    in C

    Doubt on compiler-processor relationship

    Let's say we are using the gcc compiler, and a Pentium 4. Also say there is another machine running same gcc compiler, but a different processor, say Sunsparc. So, now, even though only the processor differs, yet different machine codes will be generated for the same code. (I assume it to be the case, kindly correct me I am wrong..)

    Now how does the compiler know that what machine code to generate. (I presume it has got to do something...
    See more | Go to post

  • Hmm Ok, I think I need some more explanations. Ok Let's go step by step

    1) Let's say we are using the gcc compiler, and a Pentium 4. Also say there is another machine running same gcc compiler, but a different processor, say Sunsparc. So, now, even though only the processor differs, yet different machine codes will be generated for the same code. (I assume it to be the case, kindly correct me I am wrong..)

    Now how does...
    See more | Go to post

    Leave a comment:


  • ajaygargnsit
    started a topic OK .. So we think we know how to run a program.
    in C

    OK .. So we think we know how to run a program.

    Hey, I just ported one of my programs from gcc to turbo c compiler, and noted a strange thing. I used a structure

    struct s
    {
    int a;
    char b;
    }obj;

    on gcc, sizeof(obj) gave 8, (4 for int, 1+3 for char due to padding);
    while on turbo c, sizeof(obj) gave plain 3 (2 for int, 1 for char).

    Now I took the value of a to fit into two bytes, and the program seemed to show...
    See more | Go to post

  • ajaygargnsit
    replied to A small doubt on ptrdiff_t
    in C
    well, if that is the case, then why do we need ptrdiff_t at the first place. Can it not be that the pointer difference be stored in a long variable, since we are ultimately casting it to long type itself in printf statement ?

    Any ideas?...
    See more | Go to post

    Leave a comment:


  • ajaygargnsit
    replied to A small doubt on ptrdiff_t
    in C
    well, if that is the case, then why do we need ptrdiff_t at the first place. Can it not be that the pointer difference be stored in a long variable, since we are ultimately casting it to long type itself in printf statement ?

    Any ideas?
    See more | Go to post

    Leave a comment:


  • ajaygargnsit
    started a topic A small doubt on ptrdiff_t
    in C

    A small doubt on ptrdiff_t

    Hi

    I am clear about the nuisances about ptrdiff_t. There is just one thing that I need to know :

    Suppose we need to display the value of an object (say 'x') of ptrdiff_t. Then what format specifier should be used, assuming I am using printf tp print on stdput ??
    See more | Go to post
No activity results to display
Show More
Working...