blog.grace.moe

Source for the blog blog.grace.moe
git clone https://git.grace.moe/blog.grace.moe
Log | Files | Refs

commit 845d239c7e14e213dd95f0c4207652ec6149147c
parent b47050441301c5cbabfb7efaf274f8204e4e9ece
Author: gracefu <81774659+gracefuu@users.noreply.github.com>
Date:   Mon, 14 Apr 2025 16:12:26 +0800

Add secret page

Diffstat:
Acontent/cs3211.smd | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+), 0 deletions(-)

diff --git a/content/cs3211.smd b/content/cs3211.smd @@ -0,0 +1,58 @@ +--- +.title = "CS3211 Tutorial 10", +.date = @date("2025-04-14T16:12:01+08:00"), +.author = "Grace Tan", +.description = "CS3211 Tutorial 10", +.layout = "page.shtml", +.draft = false, +--- + +# CS3211 Tutorial 10 + +(Will delete after a few weeks) + +(Will be ready like maybe tomorrow) + +## Overall themes in CS3211 + +- How to specify concurrency. + - Use std::thread, goroutines, async tasks, scoped threads, Rayon, ... +- How to deal with synchronization. + - Use std::mutex, channels, ... +- The rules around concurrency. + - C++ memory model, borrow checking. + +Ultimately, all these themes show up in other languages as well! + +e.g. asyncio in Python https://docs.python.org/3/library/asyncio-task.html + +## Overall trend + +- **C++**: Do synchronization manually, put everything in shared memory. +- **Go**: Shared memory is bad because races, put everything in channels. +- **Rust**: Channels are slow and prone to deadlocks, structure the code itself so you don't have these problems. +- **Future languages**: Even Rust doesn't do structured concurrency the best, solve problems magically... + +## Channels are bad + +https://www.jtolio.com/2016/03/go-channels-are-bad-and-you-should-feel-bad/ + +https://news.ycombinator.com/item?id=43670373 + +## Exam prep + +- Don't rush through the MCQ portion, don't forget that's actually the majority of the marks! +- Practice questions available on Canvas. + +## My approach for solving the memory model questions + +- Try to understand the rough structure of the code. + - Pay attention to infinite while loops! +- If there's a chance for a data race, try to check those first. +- Then solve each T/F question. + +## Open ended coding questions + +Remember we're trying to test for your knowledge in what we taught in the module, not necessarily whether you know all the syntax perfectly. So don't stress too much about getting the correct function name etc., just write something that indicates you know the concept! + +Some parts you shouldn't handwave away though --- remember the goal is to show you understood the module. So for example, when answering a Go question, the flow of the data and how the channels are set up is very important to make clear!