Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

What goes on inside CPU when a process is loaded?

null
0
ashfawad
Asked:
ashfawad
1 Solution
 
braveheartCommented:
The operating system does not necessarily know how much space to allocate to a program beforehand. It knows how much code space and data space because these contain the instructions and constants that make up the program. The stack segment grows and shrinks according to the run time requirements of the program.

For instance, when a subroutine or function is called, the context of the calling routine has to be saved by pushing values of variables on to the stack. Similarly some call might allocate a block of memory to the program - the operating system can not know this until run time, so the stack grows and shrinks as necessary.

Different strategies are used by different systems: some might allocate a fixed maximum to the size of the stack, while others will include the stack in virtual memory so that it can grow and shrink without limit and so that it any memory not used is available to other processes.

If you execute vi on any file, the data segment contains the constants in the vi program, not any data associated with the file. The file remains stored on disk, although some of its contents may be cached in local memory and, almost certainly, things like file descriptors may be stored in the stack segment of the process, if the vi program requires it.

An I/O wait is as long as it takes. The scheduler will judge whether the file reading process is waiting for I/O and, if the I/O transfer is not yet complete, it will go on to the next process. The length of wait depends on the speed of your disks, or network, the speed of your CPU... you name it.

Why not read "Fundamentals of Operating Systems" by A.M.Lister, published by Macmillan. It is a bit old but is very UNIX oriented.
0
 
ashfawadAuthor Commented:
Thanks for the answer and also the  book. I I hope thsi book does not confuse me further. None of the books give detailed explaination. They miss out a lot of things.

0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now