Saturday, March 20, 2004

OS stuff

Have you gone into details about what happens when an app is executed? Like what does the OS do? OS Loader, creating new process etc

the book i refered to was Modern Operating Systems by Andrew Tanenbaum. (i read a shorter earlier edition). the sample pdf's are worth looking at.

the major portions of the book i focussed on were processes and threads, inter-process communication(ipc), deadlocks, memory management, file systems. also the author had a *nix bias but wrote that win 2000 was better than linux in the design. linux is not as well structured.

in the book a more general conceptual view is provided. on processes and threads he explains why they are needed, and needs for IPC and IPC problems. Semaphores, Mutex locks, sleep and wake up, Monitors are important. similar concepts wait/sleep/interrupt are used in java api's. also a new concurreny utilities package has been added in java 1.5.

"The concurrency utility library provides powerful, high-level thread constructs, including executors, which are a thread task framework, thread safe queues, Timers, locks (including atomic ones)and other synchronization primitives."

so now you can create Semaphore s = new Semaphore(1,true); etc and work on a higher level than simple wait/sleep. is there a similar api in .net?

back to the book, memory management explains why swapping, virtual memory were needed and implemented. any part you interested in, i can try to blog on. also dinesh and i flopped in the cdac test on os'es. so we're not the best at this topic. (including this so that it gets persisted .. and i remember cst2004 ).

stuff like what happens when an app is executed i cannot confirm. in linux the fork() sys call is used to spawn new processes. a parent (can be a shell) simply forks a new child process. the child process gets all the parents handles and resumes running. the first process started by the kernel is init. it has the process id (pid) 1. try $ ps -ax | head .then init spawns new child processes etc. there is also an exec() call to start a new prog. whats the difference i do not know.

executable file format if ELF. support for running ELF files has to be enabled in the kernel. so then the kernel knows what to do with an ELF binary. i just noticed that the kernel can also support MISC binaries. these include apps which need an interpreter to run, ie java, python.

so within the ELF file format it is specified as to how mem is allocated, stack heap etc.. similar stuff should be valid for exe in win.

No comments: