In stage 27 after selecting a process to swap to disk, the stack pages and the unshared heap pages of the process are swapped to the disk after which the stack pages, unshared heap pages and the code pages are released. Documentation just asks to check if the page is shared for heap pages.
"Now that, a process is selected to swap out, the TICK field for the selected process is initialized to 0. (From now on, the TICK field must count for what amount of time the process has been in memory). The code pages for the swapping-out process are released and the page table entries of the code pages are invalidated. The process selected for swapping out, can have shared heap pages. To simplify implementation, shared heap pages are not swapped out into the disk. Again, to simplify implementation, the kernel stack page is also not swapped out." - Documentation
But doesn't swapping shared code pages create an issue since we are not updating the page table of the processes sharing the code page and hence when these processes try to access the page since the valid bit is set they end up accessing the wrong page instead of an exception arising?
Or am I missing something here?