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.
...
User Profile
Collapse
-
A question on threading in Linux
-
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 !! -
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... -
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...Leave a comment:
-
@Sicarie
Well .. I don't get you Sir. Its more of a doubt of algo, not the implementation ...Leave a comment:
-
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. -
-
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 .. :( -
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..)Leave a comment:
-
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)...Leave a comment:
-
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?...Leave a comment:
-
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 ?...Leave a comment:
-
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... -
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...Leave a comment:
-
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... -
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?...Leave a comment:
-
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?Leave a comment:
-
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 ??
No activity results to display
Show More
Leave a comment: