Informatics

(Draft) Functional Programming

Best entry video Functional Programming in 40 Minutes • Russ Olsen • GOTO 2018 You can find the slide here. Mindset We don’t need to put our knowledge aside when learning functional programming. It’s more of a refactoring. Functions in mathmatics It’s just maps from set to set. Functions donn’t compute somthing in math. It just is. A thing. Once the function was defined, the input-output correspondence never changes by other factors, which means, there is no side effects.

Mutex

How to think Data race: an issue when data are accessible by multi-thread. How to solve? -> Locks, Mutual exclusion locks (a.k.a., Mutex locks) Mutex Mutex = Mutual exclution lock = a thread locks exclusively other threads until done. (Binary) Semaphor and Mutex https://stackoverflow.com/a/86021/9923806 Mutual exclusion semaphores are used to protect shared resources (data structure, file, etc..). A Binary semaphore should be used for Synchronization. Critical section https://en.wikipedia.org/wiki/Critical_section In concurrent programming, concurrent accesses to shared resources can lead to unexpected or erroneous behavior, so parts of the program where the shared resource is accessed need to be protected in ways that avoid the concurrent access.