stack 6

Chapter 3: Processes

경희대학교 허선영 교수님의 운영체제 수업을 기반으로 정리한 글입니다.Process in MemoryProcess Address Space: 메모리 중 process가 사용하는 공간 -> 4가지 섹션stack: 함수의 local variable, return address 등 (e.g., main, add)heap: 동적 objectdata: 전역 변수 text: 코드 = 명령어 (read only)※ 전역 변수 따로 저장하는 이유: stack은 함수마다 공간 존재하지만, 전역 변수는 모든 함수가 접근 1. stack각각의 함수는 stack frame을 갖게 되고, 이 frame 내에서 해당 함수가 사용하는 local variables 저장됨-> 함수 호출/return에 따라 stack 크기 업/다운 2...

CS/운영체제 2025.05.04

Programming Exercise: Lab #4

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Exercise #1ProblemsImplement linked structure STACK.~StackType(): destructorsize(): returns the length of stackpush(): pushes a new item into the stackpop(): pops and returns the item at the top of stack (if the stack is empty, return -1)StackType::~StackType(){ NodeType* tempPtr = topPtr; while (tempPtr != nullptr) { topPtr = topPtr->next; ..

CS/자료구조 2025.04.19

Chapter 5: Linked Structures (1)

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Linked Structure Array-based Stack Implementation▶ In the previous implementation, we consider an entire stack (a set of items) as a single object (array). New stack Implementation▶ Here, we consider each item in the stack a single object (Node).How could we define relationships between items? (Who's on top of whom?)Node Implementation▶ A pointer can be used..

CS/자료구조 2025.04.16

Programming Exercise: Lab #2

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Exercise #1ProblemsImplement (1) BinarySearch(int item) and (2) BinarySearchNearest(int item).Assume that there are No duplicated elements in the list.▶ (1) BinarySearch(int item) is the function we already learned in the class.The only difference is that "it returns the index of the item" if foundOtherwise, it returns -1template int SortedType::BinarySearch..

CS/자료구조 2025.04.06

Chapter 3: Stack

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.StackWhat is Stack?▶ Logical (or ADT) level Stack is a group of homogeneous items (elements).Removal (pop) and addition (push) of stack items can only occur at the top of the stack. A stack is a LIFO "Last In, First Out" structure.e.g., Undo(무효로 하다, Ctrl + z), Back (browser 뒤로가기), Stack trace ※ stack trace: 프로그램에서 에러가 발생했을 때, 문제를 추적할 수 있도록 함수 호출 순서를 보여주는 로그이..

CS/자료구조 2025.03.28

Lecture 06: Instructions - Language of the Computer - 3

경희대학교 김정욱 교수님의 컴퓨터 구조 수업을 기반으로 정리한 글입니다.Explanation of 32 Registers32 Registers$zero: contains 0 value$a0 ~ $a3: function argument, 함수를 호출할 때 전달하는 인자$v0, $v1: return values, 최종 결과값을 전달할 때 사용$t0 ~ $t9: temporary register (do not have to preserve), 덮어쓰기 가능 (메모리에 저장 X)$s0 ~ $s7: saved registers (preserve), 덮어쓰기 불가능 (메모리에 저장)$gp: global pointer (to access static data ex) constant value)$sp: stack po..

CS/컴퓨터 구조 2024.10.08