https://github.com/zriyansh/atomic-variable-in-go
https://github.com/zriyansh/atomic-variable-in-go
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zriyansh/atomic-variable-in-go
- Owner: zriyansh
- Created: 2022-01-31T19:30:05.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-01T18:10:08.000Z (over 4 years ago)
- Last Synced: 2025-05-22T01:10:40.386Z (about 1 year ago)
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
atomic variable implemenation took 3 sec
mutex(multithread) implementation took 27 sec
single threaded implemenation took 37 seconds
we used atomic var bcoz we were not context switching many times over, else this would have not been a good option
in this program, our countLetters () is fast, we have to just wait for pages to load that is taking all the time.
mutex, when we apply lock to a process, we give control to the OS, then OS manages the resources of those mutexes and it wastes a few CPU cycles. Spinning locks improves this. It minimises control being transferred to OS