Linked List
25. Reverse Nodes in k-Group
82. Remove Duplicates from Sorted List II
206. Reverse Linked List
2487. Remove Nodes From Linked List
Linked List
Array
String
Hash Table
Binary Tree
The Linux kernel utilizes the task_struct structure, which can be viewed here to manage threads.struct task_struct {
...
pid_t pid;
pid_t tgid;
...
}
Every thread in a Thread Group maps to a task structure in the kernel.
The pid variable correspond to a thread ID, and tgid, meaning Thread Group ID corresponds to a process ID.User layerSystem callVariable mapped in Kernel <br/> task_struct structureThread IDpid_t gettid(void)pid_t pidProcess IDpid_t getpid(void)pid_t tgid
Use the following command to retrieve the information about threads, where LWP represents the thread ID and NLWP indicates the Number of LWPs. Additionally, the process systemd+ is multi-thread, with four threads having thread IDs 1195, 1358, 1359,and 1360.$ ps -eLF -L
This note serves as a document on thread safety analysis and implementation of mutex locks and atomic operations in the C standard library.
Invironment setting:Ubuntu Linux version: 24.04.1 LTS
gcc version: 13.3.0
II. Experiments
1. Race condition case
1.1 Implementation
Both threads in the following .c file access the static variable counter without any protection against race conditions.#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
This website serves as a documentation platform for my learning notes on computer science.
I'm a master graduate in electronic engineer from NCKU.
About me:Medium
GitHub
Environment Setting:Ubuntu Linux: 24.04.1 LTS
gcc: 13.3.0
What is segmentation fault?
How can segmentation occurs?
II. Experiment
Case 1: Invalid write to a read-only section
int main()
I'm learning memory management using the valgrind tool and documenting it in this note.
Environment setting
Ubuntu Linux version: 24.04.1 LTS
gcc version: 13.3.0
Valgrind version: 3.22.0
II. Valgrind tool
Memory leak types:definitely lost: program is leaking memory
indirectly lost: program is leaking memory in a pointer-based structure. (E.g. if the root node of a binary tree is "definitely lost", all the children will be "indirectly lost".) If you fix the "definitely lost" leaks, the "indirectly lost" leaks should go away.