-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwcmentor161log.txt
405 lines (405 loc) · 19.4 KB
/
wcmentor161log.txt
1
<ishaan> : Hello! I am Ishaan. 1st Year<ankit> : please introduce yourself till everyone joins <Pavana> : I am Pavana.2nd year<ankit> : What about rest of you? <ankit> : introduction people<omkarp> : Omkar Prabhu first year CS<Anirudh> : I'm Anirudh. 1st Year<Mahim> : Mahim Agrawal 1st year mech<Samvid> : Samvid 2nd year CS<tushaar_> : 204:540d:ce8e:d117:4613:90e7:9873 PRIVMSG #wcmentor16 :Tushaar, 2nd Year IT.<shreyansh_> : Hii this is shreyansh : 2nd Year IT<shruthi> : Shruthi , 2nd year<ankit> : So should we wait for others?<ankit> : or should we start?<Mahim> : lets start<ankit> : ok cool <ankit> : So what is this session about?<tushaar_> : 204:540d:ce8e:d117:4613:90e7:9873 PRIVMSG #wcmentor16 :OS.<tushaar_> : 204:540d:ce8e:d117:4613:90e7:9873 PRIVMSG #wcmentor16 :Right?<ishaan> : Operating Systems<ankit> : You tell me Tushaar, you joined right?<tushaar_> : 204:540d:ce8e:d117:4613:90e7:9873 PRIVMSG #wcmentor16 :Yes!<tushaar_> : 204:540d:ce8e:d117:4613:90e7:9873 PRIVMSG #wcmentor16 :Operating Systems.<ankit> : Cool so everyone name your favourite operating system<ishaan> : Android!<tushaar_> : 204:540d:ce8e:d117:4613:90e7:9873 PRIVMSG #wcmentor16 :Linux.<niharock69> : hi i m nihar 1st year IT<niharock69> : sorry for joining late<Mahim> : windows<Anirudh> : Android<niharock69> : Android<shreyansh_> : Linux and android<Pavana> : Windows<ankit> : No problem, everyone is naming their favourite os<ankit> : done?<ankit> : Cool, whoever said android, it built on linux, so you can say you like linux too<ishaan> : cool<ankit> : So, this session is gonna be a informal one, feel free to interrupt me anywhere <ankit> : Can someone tell me what can be a definition of OS?<Anirudh> : Like Andriod is iOS also based on some other OS<ankit> : iOS is based on unix but Apple has customised it a lot <niharock69> : operating system is a software which acts as an interface between us and other programs<ankit> : so what are these other programs?<ishaan> : applications?<niharock69> : other programs meaning other softwares like google chrome<ankit> : ok yea that's the most basic definition of OS<ankit> : I won't talk much about the history of OS, lets start with processes<niharock69> : ok<ishaan> : ok!<ankit> : So anyone knows what is a process?<niharock69> : no<ishaan> : no<puneet> : any program currently running?<ankit> : correct Puneet <puneet> : like in task manager there are processes running and we 'end' them.<tushaar> : A program in execution.<ankit> : so what is a program <tushaar> : Sequence of instructions.<ishaan> : set of codes?<Anirudh> : Set of instructions<niharock69> : sequence of codes which run according to instructions<ankit> : yea, all are more or less the same thing and basic definition of program <ankit> : and a program under execution is process<puneet> : yolo! could you tell me how you log chats!<ankit> : so how many processes are running on your system right now?<Anirudh> : about 50 to 60 ?<Mahim> : 134<ishaan> : around 80<ankit> : linux users do a cat /proc/stat and tell me the first number <ankit> : cat /proc/stat<Samvid> : 145<niharock69> : 2901<ankit> : how are you seeing these numbers like 134/145?<niharock69> : is it something unusual to get such a huge number ? :P<Mahim> : task manager under processes tab<Mahim> : summed up the apps, windows processes and background processes<ankit> : 53894 that's mine currently <ankit> : Task manager will show you the count of processes which you can handle without screwing up your system <ankit> : so yea the first job of an OS is process management <ankit> : let's consider a single core system for the ease of discussion cool?<ishaan> : okay<niharock69> : ok :)<puneet> : ok<Pavana> : Ok<Anirudh> : ok<ankit> : so what did you understand from that? <shreyansh_> : what does core actually mean?<ankit> : @shreyansh good, I was expecting that question <ankit> : so you can take core as a synonym for CPU <shreyansh_> : i know only types of core mean dual,quad like that<ankit> : currently you would hear words like dual, quad, hexa, octa etc<ankit> : infront of cores<niharock69> : yea<shreyansh_> : okk fine !<ishaan> : yeah<suhasbs> : Single core means the CPU can only handle one process at a time?<ankit> : it just means those systems has that many processing unit <ankit> : https://www.d.umn.edu/~gshute/os/images/process-diagram.png<ankit> : see that image <ankit> : it shows life cycle of a process <ankit> : saw?<ishaan> : yes<puneet> : yep<Vilas> : Yes<Pavana> : Yes<Anirudh> : yes<ankit> : so a single core system means only one process can be in the running state at a time <suhasbs> : Yes<ishaan> : what happens to the process after it has been terminated?<ujdcodr> : it dies<suhasbs> : It is said to be dead<ankit> : its destructor is called, its memort is deallocated <ankit> : memory*<ishaan> : ok :)<suhasbs> : What does the ps command actually show?<ankit> : so in an os, there are many process queues <ankit> : ps shows process in that space<suhasbs> : Ooh OK.<ankit> : so you see the state ready?<ankit> : in the image?<ishaan> : yes<puneet> : yes<niharock69> : yes<Pavana> : Yes<ankit> : every OS has something called a ready queue <ankit> : ready queue contains processes which are ready to run <ankit> : Anyone heard about process control block? (PCB)<ishaan> : no<omkarp> : no<Pavana> : No<shreyansh_> : Nope<ankit> : so a PCB stores all the information about a process <ishaan> : ok!<ankit> : like the memory address currently used by the process <ankit> : can someone tell me difference in memory allocation of local variable and global variable?<niharock69> : the address of local variable can be used only inside the function<niharock69> : but for globall it can be used throughpout the program<ankit> : how many competitive programmers here?<puneet> : Vilas!<Vilas> : me. global variables are stored in the heap while local in the stack i guess<ankit> : yes <ankit> : what are these stack and heap?<omkarp> : data structures<Vilas> : stack is allocated to a specific program. <ankit> : ok that is one, but stack is the memory allocated in RAM and heap is allocated in the main memory <ankit> : heap is dynamically allocated during run time <ankit> : if any word is unclear, please ask?<niharock69> : clear<ishaan> : then what about stack?<niharock69> : :)<ankit> : stack is statically allocated to every process <ishaan> : ok! :)<ankit> : That's why Vilas will ask everyone to store large arrays as a global variable :P<ankit> : because stack can run out of space but heap will keep getting more memory <ankit> : That is where "stack overflow" happens <puneet> : hey, aren't main memory and ram the same?<ankit> : Oh I mean Stack is in the memory already allocated to the process in beginning <ankit> : Yea my bad they are same <niharock69> : so the only differenece is stack is created while compiling and heap while runtime is it so?<ankit> : yes <niharock69> : ok!<ankit> : so yea back to PCB, a PCB stores all these information <ankit> : what is memory range of stack, what is of heap and so on <ishaan> : ok!<ankit> : so say you run a program <ankit> : it runs as a process and it first enters the ready state and hence in a ready queue <ankit> : and from there is no process running currently, the head of ready queue starts running <ujdcodr> : can you clarify again where the heap and stack are respectively stored?<ankit> : ok so when you run your program, based on the compile time information, stack is allocated the memory <ankit> : and then when your program starts running, when it encounters something like a malloc, it gets memory in malloc <ankit> : http://static.duartes.org/img/blogPosts/linuxFlexibleAddressSpaceLayout.png<ankit> : check that image <ankit> : that is how they are allocated <ankit> : stack has a limited expansion space denoted by Rlimit <ankit> : but heap can expand (till you have memory theoritically)<ankit> : ujjwal clear?<niharock69> : whats Rlimit?<ankit> : its just the memory limit of stack <ujdcodr> : yep<ankit> : you stack can't be larger than that <niharock69> : ok<ankit> : so yea <ankit> : so the way you send process from ready queue to run is called scheduling <ankit> : Has anyone heard of different process scheduling techniques?<niharock69> : no<tushaar> : Scheduling jobs?<ishaan> : no<puneet> : nope<Pavana> : No<ankit> : nope Tushaar just algorithms <ankit> : so the simplest scheduling technique is FIFO <tushaar> : First come first serve?<ankit> : what do you think that will be <puneet> : thats a queue?<ankit> : yea first come first serve <niharock69> : first in first out<ankit> : so the first process which comes in the queue gets to run first <ankit> : like a simple queue <ankit> : what do you think is a problem with this?<tushaar> : Time.<Vilas> : Priorities are neglected <Samvid> : the processes with higher priorities have to wait if they start after the ones with lower priorites<niharock69> : suppose a small process comes later and before that theres a very huge process the small process has to wait for a very large amount of time<tushaar> : If the first job takes lot of time, all other jobs must stall.<ankit> : yes nihar <niharock69> : :)<ankit> : priorities is also a problem but nihar's answer is a bigger problem <ankit> : that is called convoy effect <ankit> : what is a convoy?<ankit> : english meaning <tushaar> : A group of ships, travelling together.<tushaar> : for protection.<ankit> : yea, its like a large group <ankit> : so when a small ship is trying to dock behind a convoy what will happen <ankit> : same things happens in FCFS <shreyansh_> : FCFS???<ankit> : first come first serve <ishaan> : first come first serve<shreyansh_> : okay got it<ankit> : see a simple example, if a person in atm line goes in with 5 cards ahead of you when you just need 100 bucks <ishaan> : lol. yeah :P<ankit> : as for the priority problem, it was solved by bringing in a priority fifo <ankit> : in priority fifo, when a process with higher priority comes, a smaller priority process is preempted <ankit> : clear?<ishaan> : yes<ankit> : so what is a problem with priority fifo which was not there in fifo <ishaan> : it is not order based?<puneet> : incoming process's priority must be checked with all the processes presently in the queue this taking some time?<ankit> : that is one puneet but not a big one <niharock69> : processes quitting before completion because of priority issues?<ankit> : consider you are in an ATM line and whenever you come in first of line, the MLA, the MP and even the PM comes to same ATM (hypothetically)<ishaan> : it is not based on the order<ankit> : you will never get your cash <tushaar> : It is not-fair for lower priority jobs, inspite of them arriving first?<tushaar> : :)<niharock69> : oh yeaaaaaaa<ankit> : same happens with the low priority process as Tushaar said <ankit> : its called starvation <ankit> : similarly there are a few more scheduling algorithms, which you should read by yourself <ankit> : Now I will talk a bit about parallelisation <niharock69> : ok<ishaan> : ok<ankit> : first practical aspect, how do you create a process in C?<ankit> : anyone?<suhasbs> : Fork()<ankit> : yes, how does fork work?<ankit> : like what do you see<ankit> : not the kernel level detail <suhasbs> : It returns a process id<puneet> : it creates a copy of the currently running process and runs it parralelly?<ankit> : yes, it copies the instructions from the point it was called <ankit> : printf("hi");<ankit> : fork();<ankit> : printf("hello");<ankit> : what do you think will be the output <puneet> : hihihello?<puneet> : hihellohello*<ankit> : hihellohello is correct <ankit> : is it clear to everyone why that happened?<niharock69> : no<niharock69> : y does iyt happen<niharock69> : it shld just print hihello ryt<ankit> : ok so<ankit> : when you encounter fork, a new process is created, which executes all the statements after fork <ankit> : this process is called child process <ankit> : so your parent process prints hi <niharock69> : ohh<ankit> : then there are two process running cause there is a fork <ankit> : then one process first prints hello <ankit> : and then second prints hello <niharock69> : got it :)<suhasbs> : So something like a new thread is created and everything below fork is like as though its inside the run method?<ankit> : ok yea that reminds me, what is a thread and what is a process<suhasbs> : Was about to ask that question!<ankit> : ok so threads are used for smaller tasks <ankit> : threads are created by processes and all the threads of one process shares the same memory space <ankit> : but this does not happen with process <ankit> : every process has a memory space independent of each other <niharock69> : ok<ankit> : now back to fork, how many process do you think will be created by fork();fork();fork();<niharock69> : 3! ?<niharock69> : that is 6?<ankit> : others?<tushaar> : 8.<suhasbs> : 1<ankit> : everyone logic behind your answers <tushaar> : 2 - 2 + 2 - 2+2 2+2.<niharock69> : first fork will create 1 process inside that one more process inside that one more process<niharock69> : and all these returning will caause 3! processes<ankit> : suhas?<ankit> : ok Tushaar answered correct <suhasbs> : Just guessed<ankit> : after first fork - 2 process <puneet> : is it 7 + 1 parent? or 8 children?<ankit> : 7+1<puneet> : okay. got it.<ankit> : both these process will execute second fork, hence 2*2 = 4 <ankit> : and all these 4 processes will execute the last fork so 4*2 = 8<ishaan> : ok!<niharock69> : so basically 2^n processes?<suhasbs> : Ooh OK<ankit> : yes nihar <ankit> : 2^n -1 children and 1 parent<niharock69> : ok :)<ankit> : apart from fork there is something called openmp, which can create parallelisation in C <ankit> : check that out <ankit> : I think I will conduct two more sessions on OS, I will end this session with a question <niharock69> : okkk<puneet> : okay!<Pavana> : Ok<ishaan> : ok!<ankit> : before that one more concept I forgot <ishaan> : ohh<ankit> : How do processes communicate with each other <ankit> : there are two methods <ankit> : 1) shared memory<ankit> : 2) message passing <ankit> : Message passing is similar to a socket communication of networks <ankit> : puneet explain what's that :P<puneet> : :D, okay.<puneet> : basically, a socket is end point of a communication channel.<ishaan> : ok...<ankit> : so yea <puneet> : so, a host who wants to create a server creates a socket, binds the socket to its address.<puneet> : then listens in the socket for incoming connections.<niharock69> : okkk<puneet> : meanwhile, a client opens a socket and connects to a existing host in the network<ankit> : a process can create a socket for itself and let other processes talk to it, or two processes can create use something call mailboxes and talk to each other by passing messages <suhasbs> : A socket is basically a combination of a port and IP address, for those who are wondering what socket is!<puneet> : your explanations are better ankit :p<ankit> : in a local system its just the port <ankit> : message passing is similar to sending and receiving letters <ankit> : socket and mailboxes are just the address where letter can be sent <shreyansh_> : port?? :(<ankit> : read about network port, its a computer network based concept <ankit> : you can just think of it as an identifier <ankit> : in your system for network communication <ankit> : like if message comes with port number 8080, send it to your browser <niharock69> : yeaaaa<ankit> : so the second method is shared memory <ankit> : shared memory is how you talk to your benchmate in the class of a strict prof :P<ankit> : now you tell me how you do it <puneet> : is forking a way to do shared memory communication?<tushaar> : Whisper.<ankit> : no forking is just process creation <puneet> : write it down in a paper would be better tushaar :p<ankit> : you can communicate in either way between those processes <ankit> : exactly at puneet <tushaar> : Oh yeah!<ankit> : the paper is a shared medium <ankit> : you write, "I am feeling so sleepy" and he replies with "me too"<niharock69> : so in shared medium we need a medium for communication<niharock69> : ubt in message sharing we did not require<ankit> : so similar happens in shared memory, OS allocates a chunk of memory to two process <ankit> : and they communicate by putting information in this shared space so other can read from here <ishaan> : ohhh<ankit> : so back to my question <ishaan> : cool<ankit> : say two processes share a variable, and one process is increasing it and other is decreasing it, what kind of problems may arise and how can they be solved?<puneet> : in message sharing, we did use a medium @niharock69. thats why it needed a socket.<tushaar> : Synchronization can solve.<ankit> : tushaar thats the assignment :P<niharock69> : okkk<tushaar> : Okay :)<puneet> : okay.<ankit> : find out different methods <ankit> : there are at least 7 common ones <ankit> : first identify the problem <ankit> : cool? I will pass the message when I schedule the next one <tushaar> : Awesome!<puneet> : yep!<ishaan> : cool!<ankit> : Thank you <Pavana> : Ok<niharock69> : ok<niharock69> : thank u :)<ishaan> : Thank You<niharock69> : very nice session<Pavana> : Thank you<omkarp> : thank you for the session<puneet> : thanks!<ankit> : I will on this channel for 10 15 min if anyone has doubts <shreyansh_> : 'a host who wants to create a server creates a socket, binds the socket to its address then listens in the socket for incoming connections"....i didnt get it completely<ankit> : ok you will get that if you actually write a socket program yourself <shreyansh_> : okay!<ankit> : A client server architecture is a request response architecture, where client makes a request and server responds with the replies with the answer. Implementation goes like:<ankit> : Server side:<ankit> : Server is alloted a port number to listen to<ankit> : Server waits for a client to connect <ankit> : When a client requests connection on the listening port, server allots a new port to the client and server goes back to listen on the listening port<ankit> : Client and server talk on the other port<ankit> : Client side:<ankit> : Client is alloted a port<ankit> : It makes a connection request to the server and talks on the port given by the server<ankit> : The kind of communication which sockets provide is called message passing. It's a common method of remote communication. The other prominent kind of communication is shared memory, which is used by operating systems for inter process communication within same system. <ankit> : Other concepts you will need to know before is loopback address (127.0.0.1), its the IP address of your local system. <ankit> : Also, as we mentioned before first 1024 ports are reserved, you can't start a connection using any of these port number. <ankit> : Also, the reason I made "no python" rule was because it will be a 3 line code and you will not learn anything. I will discuss more socket concept informally on whatsapp. Please be proactive with your doubts.<ankit> : Log of session: https://github.com/adeepkit01/logger/blob/master/wcnetworkslog.txt<ankit> : Tutorials:<ankit> : http://www.cs.rpi.edu/~moorthy/Courses/os98/Pgms/socket.html<ankit> : http://www.javaworld.com/article/2077322/core-java/core-java-sockets-programming-in-java-a-tutorial.html<ankit> : Thanks, <ankit> : Ankit<ankit> : That's something you can refer