I am implementing a sliding window for a trivial protocol. I was implementing the window using a static circular queue (array), as i though it is efficient.
But one of my friends said, he has seen the implementation of sliding window in tcp, it uses a linked list. I dont think he has seen, as he doesnot know where is network code located...
because obj, the playingCard object is created inside a nested for loop does that mean after the second for loop completes, obj gets deallocated from the stack each time?
and a small side question,
does a compiler use the stack (similar to recursion) to keep track of loops and nested loops?
for(int c = 0;c<nElems;c++) {
for(int...
I have a Stack object being worked on by multiple threads. One of the threads is a worker thread which performs a pop operation on the Stack object. I wanted to handle the case where the Stack is empty and I see two options
try{
Object obj = (Object) d_stackObj.pop();
}
catch (EmptyStackException e)
{ ...}
OR
if( ! d_sta...
Hello,
I am looking for a configurable / tunable on Solaris 9 through which I can change the default thread stack size without recompiling the code to use "pthread_attr_setstacksize"
For example on HPUX 11.11 / 11.23 the environment variable "PTHREAD_DEFAULT_STACK_SIZE" can be exported (available via HPUX patches PHCO_38307 / PHCO_3895...
If I declare a data structure globally in a C++ application , does it consume stack memory or heap memory ?
For eg
struct AAA
{
.../.../.
../../..
}arr[59652323];
...
I am working on a Windows program codebase that has heretofore been 32-bit. I am trying to make this codebase 64-bit clean. Turning on “top down” allocations in the heap manager by setting the “AllocationPreference” registry value has been very helpful in turning up bugs where code was guilty of coercing pointers down to 32-bit values (s...
Hi,
I know that local variables and paramters of methods live in stack, but I not able to figure out where does actually methods live in case of Java?
If I declare any Thread object like:
Thread t=new Thread();
t.start();
So it means I've created a separate calling of methods apart from main method. What does it mean? Does it mean c...
How are the they all related as well?
(Code samples would be appreciated!!!)
Edit: Given the fact that I didn't know these terms were this overloaded, let me clarify:
By stack, I don't mean the data structure stack. By frame, I mean stack frame. And heap, well, I think I mighhhht be okay on that one...
...
I come from a C# background but I'm currently learning C atm. In C#, when one wants to signal that an error has occurred, you throw an exception. But what do you do in C ?
Say for example you have a stack with push and pop functions. What is the best way to signal that the stack is empty during a pop ? What do you return from that f...
I was just playing with the call stack, trying to change the return address of a function etc, and wound up writing this program in C:
#include<stdio.h>
void trace(int);
void func3(int);
void func2(int);
void func1(int);
int main(){
int a = 0xAAAA1111;
func1(0xFCFCFC01);
return 0;
}
void func1(int a){
int loc = 0...
How can I find out who created a Thread in Java?
Imagine the following: You use ~30 third party JARs in a complex plugin environment. You start it up, run lots of code, do some calculations and finally call shutdown().
This life-cycle usually works fine, except that on every run some (non-daemonic) threads remain dangling. This would...
I recently wasted about half an hour tracking down this odd behavior in NSLog(...):
NSString *text = @"abc";
long long num = 123;
NSLog(@"num=%lld, text=%@",num,text); //(A)
NSLog(@"num=%d, text=%@",num,text); //(B)
Line (A) prints the expected "num=123, text=abc", but line (B) prints "num=123, text=(null)".
Obviously, printing a lon...
I'm using an obscure language that doesn't have a native stack type so I've implemented my own. Now, reading on the net i've found a few different approaches to do this.
This is my implementation (psuedo code)
//push method
function Push(int)
{
Increase (realloc) stack by 4 bytes;
Push int into the new memory area;
}
//pop met...
Let's say that I have the following code in C that represents a stack :
#define MAX 1000
int arr[MAX];
static int counter = 0;
isstackempty()
{
return counter <= 0;
}
void push(int n)
{
if (counter >= MAX) {
printf("Stack is full. Couldn't push %d", n);
return;
}
arr[counter++] = n;
}
int pop(int* n)
...
So, this is an efficiency question.
I have two collections - an ArrayList and a Stack. I use the stack because I needed some simple pop/push functionality for this bit of code. The ArrayList is essentially the out variable as this is a small section of code in the function.
So, I the variables are defined as such, then code is run to ...
I know that on Symbian stack size is equal to 8k. What about BlackBerry?
...
I have a class non-static member function, and it has variable arguments, I'm compiling on Visual Studio 2005, with the 64-bit runtime, on 64-bit Windows.
void Class::Foo(void* ptr,...)
{
va_list args;
va_start(args,ptr);
float f=va_arg(args,float);
va_end(args)
}
I'm expecting a float, I pass a float to the function. ...
I am having trouble understanding a question. The question asks first to write a C++ class to represent a stack of integers. Done. Here are my prototypes:
class Stack{
private:
int top;
int item[100];
public:
Stack() {top = -1;}
~Stack();
void push(int x) {item[++top] = x;}
int pop() {return item[top--];}
int...
Hi: down to business:
I need to know whether, when a class method in C++ is called, the implicit 'this' pointer is the first argument, or the last. i.e: whether it is pushed onto the stack first or last.
In other words, I'm asking whether a class method, being called, is taken by the compiler to be:
int foo::bar(foo *const this, int a...
In C on Solaris 10, I'd like to get the call stack from an arbitrary thread within a process.
I have many worker threads and one thread which monitors them all to detect tight loops and deadlocks. The function I'd like to implement is for the monitoring thread to print the call stack from the "hung" thread several times before it kills...