What is the relationship between system calls and CPU time slices, and is there atomicity?

when I read a book, I learned that write system calls can be considered atomic. So I was a little curious:

  1. if a process calls write at the end of its time slice, the write call is not completed by the time the process should have been switched. So what happens? Will the kernel automatically extend its time slice until the call is complete, or will it still switch to another process according to the established time slice plan, leaving the original process in write ?
  2. if two different processes simultaneously call write to write the same file (the system is multicore, so it is really "simultaneous"). For example, if you write "1111" and "2222" respectively, is it possible to have "11221122" under certain circumstances? (you won"t be confused after a personal attempt, but I wonder if there is any special situation in which this disorder can occur.)
Jun.22,2021

do you know what atomicity means? Can it be called atomicity if it is deranged?

Menu