stack

Assembly Call Stack - Terminology Questions

只谈情不闲聊 提交于 2019-12-04 04:50:36
问题 I'm completely new to Assembly and looking to confirm where, in the following statements, I have a misunderstanding and need to be corrected. The stack pointer ( ESP ) refers to the top (lowest memory address) of the stack. The base Pointer ( EBP ) is used for temporarily storing various memory addresses when building a stack frame. It normally holds the highest memory address of the current stack frame. The instruction pointer ( EIP ) refers to the memory address of a line of code in the

Does there exist Kernel stack for each process ?

[亡魂溺海] 提交于 2019-12-04 04:24:53
Does there exist a Kernel stack and a user-space stack for each user space process? If both stacks exist, there should be 2 stack pointers for each user space process right? In Linux, each task (userspace or kernel thread) has a kernel stack of either 8kb or 4kb, depending on kernel configuration. There are indeed separate stack pointers, however, only one is present in the CPU at any given time; if userspace code is running, the kernel stack pointer to be used on exceptions or interrupts is specified by the task-state segment, and if kernel code is running, the user stack pointer is saved in

Multiple threads calling the same function

时光总嘲笑我的痴心妄想 提交于 2019-12-04 03:59:58
Suppose we have multiple threads all calling the same function: def foo # do stuff ... end 100.times do |i| Thread.new do foo end end If two or more threads are currently inside of foo , do they each share the same local variables within foo ? This relates to my second question. Do threads have individual stack frames, or do they share stack frames within a single process? Specifically, when multiple threads each invoke foo and before foo returns, are there multiple copies of foo on the stack, each with their own local variables, or is there only one copy of foo on the stack? Yes, they share

Unable to get thread dump? Any ideas why my app blocks?

送分小仙女□ 提交于 2019-12-04 03:51:15
I have a basic java server app that has 100 worker threads that do simple HEAD requests on urls. I'm using HttpClient 4.x for this. A few minutes into the run my program just freezes for a couple minutes and I cannot figure out why. Check out the screen shot of what visual vm monitor reports. You can see it flatline. During this time I'm unable to get a good thread dump and visual vm just freezes until it's unblocked. Does anyone have any ideas on what I can do to try and start debugging this guy? Visual VM: http://tinypic.com/view.php?pic=2i915bs&s=7 Here is the output when I tried to take a

Call to _freea really necessary?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 03:48:17
I am developping on Windows with DevStudio, in C/C++ unmanaged. I want to allocate some memory on the stack instead of the heap because I don't want to have to deal with releasing that memory manually (I know about smart pointers and all those things. I have a very specific case of memory allocation I need to deal with), similar to the use of A2W() and W2A() macros. _alloca does that, but it is deprecated. It is suggested to use malloca instead. But _malloca documentation says that a call to ___freea is mandatory for each call to _malloca. It then defeats my purpose to use _malloca, I will use

How to manage activity stack?

烈酒焚心 提交于 2019-12-04 03:23:12
When my stack is in this situation: A->B->C if I start D activity, I want that the activity stack becomes: A->D Note that activity C is a dialog. Nitin here are the steps which will do the needed: from activity C launch the activity A with a boolean fromActivityC bundled with the intent and the flag FLAG_ACTIVITY_CLEAR_TOP set . Now in the on create of the activity A check for this boolean "fromActivityC" first and if present launch the activity D else the normal flow continues. // following code can be used to get the boolean in the oncreate boolean entrypoint=this.getIntent().getExtras()

How can I print out the contents of std::stack and return its size?

こ雲淡風輕ζ 提交于 2019-12-04 03:16:42
In c++ how can I print out the contents of my stack and return its size? std::stack<int> values; values.push(1); values.push(2); values.push(3); // How do I print the stack? You could make a copy of the stack and pop items one-by-one to dump them: #include <iostream> #include <stack> #include <string> int main(int argc, const char *argv[]) { std::stack<int> stack; stack.push(1); stack.push(3); stack.push(7); stack.push(19); for (std::stack<int> dump = stack; !dump.empty(); dump.pop()) std::cout << dump.top() << '\n'; std::cout << "(" << stack.size() << " elements)\n"; return 0; } Output 19 7 3

Does C need a stack and a heap in order to run?

房东的猫 提交于 2019-12-04 03:04:37
People talk about what the stack and heap are and the differences between them. But I am curious to know that if a CPU does not support stack and heap structure, then can C run properly without a stack and a heap? paxdiablo No, it does not. Let's cover the heap first, that's easy. An implementation that does not provide a heap of any sort just needs to return NULL whenever you try to call malloc (or any other memory allocation function). That's perfectly acceptable behaviour according to the standard. In terms of the stack, it also doesn't need to provide one. ISO C11 mentions the word "stack"

Call tree for embedded software [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 03:02:30
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 months ago . Does anyone know some tools to create a call tree for C application that will run on a microcontroller (Cortex-M3)? It could be generated from source code (not ideal), object code (prefered solution), or at runtime (acceptable). I've looked at gprof, but there's still a lot missing to get it to work on an embedded system. An added bonus would be that the tool also gives the maximum stack depth.

Initialization of array on heap

坚强是说给别人听的谎言 提交于 2019-12-04 02:30:02
How do i manually initiate values in array on heap? If the array is local variable (in stack), it can be done very elegant and easy way, like this: int myArray[3] = {1,2,3}; Unfortunately, following code int * myArray = new int[3]; myArray = {1,2,3}; outputs an error by compiling error: expected primary-expression before ‘{’ token error: expected `;' before ‘{’ token Do i have to use cycle, or not-so-much-elegant way like this? myArray[0] = 1; myArray[1] = 2; myArray[2] = 3; langerra.com This is interesting: Pushing an array into a vector However, if that doesn't do it for you try the