stack

Stack operations terminating due to timeout [closed]

人盡茶涼 提交于 2020-01-06 09:01:27
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I'm working on a problem where I am to create a stack, implement a series of operations on that stack given as an array of strings (3 variations: push x , pop , inc y x ), and print out the top of the stack (or EMPTY if the stack is left empty) after each operation. Push and pop are

C program works within GDB, crashes when run on its own

橙三吉。 提交于 2020-01-06 05:44:27
问题 This is a big project, actually a virtual machine of my custom design. Under certain circumstances, program crashes with a segmentation fault every time when I run it on its own, but within GDB under those same circumstances it runs perfectly and never crashes! I am giving it the exact same parameters and input when running inside and outside GDB. So basically, I can't find the bug with GDB because it never has any problem when I use GDB. The binary has been compiled with gcc -g option. When

Error Compiling an Deterministic Pushdown Automaton in C (DPDA)

守給你的承諾、 提交于 2020-01-06 05:31:06
问题 I was reading about how to implement a DPDA and found this code in the following Internet address: http://code.zhoubot.com/, This c file implements a simple pushdown automata. The automata will read in a description of their transition function and input, perform its computation on the input, and then print their output. The input format is like: e01:e0$:000111:a:ad:aeeb$:b0eb0:b10ce:c10ce:ce$de The input is separated by a semicolon “:”, first section is “input alphabet”, second is “stack

C++ When to allocate on heap vs stack?

こ雲淡風輕ζ 提交于 2020-01-06 02:29:06
问题 Whilst asking another question (and also before) I was wondering how do I judge whether to create an object on the heap or keep it as an object on the stack? What should I ask myself about the object to make the correct allocation? 回答1: Put it on the heap if you have to, the stack if you can. What kinds of things do you need to put on the heap? Anything of varying length. Any object that might need to be null. Anything that's very large, lest you cause a stack overflow. 回答2: Simple answer.

Trying to stop an error with Stacks in python

為{幸葍}努か 提交于 2020-01-06 02:00:06
问题 I'm trying to make a program that checks to make sure that the text is balanced in terms of brackets (so (),[],{} and not (),[,{}). I can get it to work when it is balanced, and when it is not balanced when it is missing a closing bracket (like the previous example). What I can't get it to do is come back as unbalanced if I'm missing a bracket on the left ((),],{}). I know it's trying to pop from an empty stack but can't figure out how to counter act that. My teacher has it in her Stack class

C++ threads stack address range

﹥>﹥吖頭↗ 提交于 2020-01-05 12:15:37
问题 Does the C++ standard provide a guarantee about the non-overlapping nature of thread stacks (as in started by an std::thread )? In particular is there a guarantee that threads will have have their own, exclusive, allocated range in the process's address space for the thread stack? Where is this described in the standard? For example std::uintptr_t foo() { auto integer = int{0}; return std::bit_cast<std::uintptr_t>(&integer); ... } void bar(std::uint64_t id, std::atomic<std::uint64_t>& atomic)

Do the Stack and Heap both exist within your systems RAM?

半世苍凉 提交于 2020-01-05 12:13:26
问题 The question is pretty much the same as the title, do the Stack and Heap exist within the RAM at all times? Assuming Windows is the OS of the machine in question. Also, if the answer to the above question is yes, is it possible to tell the JVM to create a specific applications Stack and Heap in a different location, such as an external micro SD card? Or to just set the default Stack/Heap creation location to some location other than RAM? 回答1: Well, they might not be in RAM at all times. The

Do the Stack and Heap both exist within your systems RAM?

别说谁变了你拦得住时间么 提交于 2020-01-05 12:12:12
问题 The question is pretty much the same as the title, do the Stack and Heap exist within the RAM at all times? Assuming Windows is the OS of the machine in question. Also, if the answer to the above question is yes, is it possible to tell the JVM to create a specific applications Stack and Heap in a different location, such as an external micro SD card? Or to just set the default Stack/Heap creation location to some location other than RAM? 回答1: Well, they might not be in RAM at all times. The

current_thread_info() inline function in Linux kernel?

℡╲_俬逩灬. 提交于 2020-01-05 08:56:25
问题 I learned thread_info is stored in the bottom of stack. While looking in the source code of kernel, I'm trying to understand how to get current thread_info in linux kernel? Source code below is 13bits masking of current_stack_pointer. This is what I cannot get it. I don't understand that the position of thread_info changes. Why is it current stack pointer instead of start of stack? Please help me to understand this code /* * how to get the current stack pointer in C */ register unsigned long

Java Stack method (multipop) Beginner java

瘦欲@ 提交于 2020-01-05 08:42:29
问题 I'm trying to write a Java method to preform a "multi-pop" off a stack. It should perform a "pop" operation on a stack object k number of times. This is what I'm thinking, but it's not quite right. Any help out there? public void multipop(int k) { while (top != null) { for (int i = 0; i <= k; i++) { this.pop(); } } } 回答1: Looks like an off-by-one error. If k=1 , you will go through the loop with i=0 and i=1 . You can fix this by changing i<=k to i<k 回答2: You execute the while loop until the