Skip to content

Chapter on Concurrency and Spinlocks#1

Open
tanishqdaiya wants to merge 2 commits into
ZackyGameDev:mainfrom
tanishqdaiya:main
Open

Chapter on Concurrency and Spinlocks#1
tanishqdaiya wants to merge 2 commits into
ZackyGameDev:mainfrom
tanishqdaiya:main

Conversation

@tanishqdaiya

Copy link
Copy Markdown

Wrote the chapter explaining concurrency and the spinlock implementation in AtOS in great detail. Let me know if there are any issues.

Comment thread ch 8. Spinlocks.md
(LSE), which provide single-instruction atomic operations such as `CAS`
(compare-and-swap), `SWP` (atomic swap), and atomic arithmetic instructions.

Regardless of which ISA we use, the goal is the same: if two cores attempt to

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ISA has not appeared in full form in any earlier text that I can see, so the reader may not know what this is an abbreviation of. It is better to not abbreviate it here (where it is being mentioned for the first time).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I did expect ISA to be in common vocabulary of a person ambitious enough to write their own operating system, due to different learning paths it may not be so. I will change it to accommodate the beginners who are starting out with Operating Systems without taking a Computer Architecture course beforehand (just how I started myself)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COA related stuff can be explained in Chapter 0. That chapter is specifically to address people who took the direct learning path.

Comment thread ch 8. Spinlocks.md
`acquire` function, which lets a thread executing inside the process acquire the
lock, effectively spinning and consuming CPU cycles while waiting. Since this
is a Spinlock implementation, the thread that acquires the lock acquires it and
does its work while the other thread that also tries to acquire the lock after

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is really long. It would be better to break this into two.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. That should be done.

Comment thread ch 8. Spinlocks.md
}
```

We only cover ncli and interrupts_enabled here. The other members hopefully

@ZackyGameDev ZackyGameDev Jul 3, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is nice that you are giving this disclaimer, but I think it might be better to move this to after you explain ncli and interrupts_enabled. Because it would be smoother in my opinion if the readers have understood ncli and interrupts_enabled before they read this when they're progressing further.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking a long off route to explain something would, in my opinion, will break the logical chain of reasoning. If you do want it however, I might be able to pull that off.

Comment thread ch 8. Spinlocks.md

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the few nitpicks aside, this is an exquisitely written chapter. You successfully explain everything, assure the reader if you mention something they may not know yet, and carefully introduce things without expecting the reader to know them beforehand. It matches the style of the rest of the documentation extremely well. Very good work.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@ZackyGameDev ZackyGameDev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can take your time addressing these comments. Because this will be merged only after the preceding chapters have been written.

@tanishqdaiya tanishqdaiya left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requested suggestions are mostly accepted, but there is some nuance about the methodology taken in the interrupt explanation. Let us see where that goes.

Comment thread ch 8. Spinlocks.md

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

Comment thread ch 8. Spinlocks.md
}
```

We only cover ncli and interrupts_enabled here. The other members hopefully

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking a long off route to explain something would, in my opinion, will break the logical chain of reasoning. If you do want it however, I might be able to pull that off.

Comment thread ch 8. Spinlocks.md
`acquire` function, which lets a thread executing inside the process acquire the
lock, effectively spinning and consuming CPU cycles while waiting. Since this
is a Spinlock implementation, the thread that acquires the lock acquires it and
does its work while the other thread that also tries to acquire the lock after

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. That should be done.

Comment thread ch 8. Spinlocks.md
(LSE), which provide single-instruction atomic operations such as `CAS`
(compare-and-swap), `SWP` (atomic swap), and atomic arithmetic instructions.

Regardless of which ISA we use, the goal is the same: if two cores attempt to

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I did expect ISA to be in common vocabulary of a person ambitious enough to write their own operating system, due to different learning paths it may not be so. I will change it to accommodate the beginners who are starting out with Operating Systems without taking a Computer Architecture course beforehand (just how I started myself)

@ZackyGameDev

Copy link
Copy Markdown
Owner

Also it appears that scheduling might end up being Chapter 8. Spinlocks will need to be from chapter 9. Please rename it accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants