Re: [algogeeks] Doubts about realloc
yes realloc can be used to shrink the allocated memory. yes the remaining memory will be freed. IF we want to allocate more memory and if there is no enough room in that particular boundary, i will allocate a new block ,copy the contents and free the previous contents On Thu, Sep 22, 2011 at 10:31 PM, Ankuj Gupta ankuj2...@gmail.com wrote: Hi I have a doubt in functioning of realloc. Can we use realloc to shrink the memory already allocated ? If yes, will it also free the left over memory or programmer has to do it ? Also, while reallocating if it has to move to some other location does the earlier location gets freed or is it implementation dependent Thanks Ankuj -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Doubts
@aditya and dipankar: the ans given ws 500ns that is why i posted dis ques...i ws getting the same ans... On Tue, Aug 9, 2011 at 9:45 AM, ankit sambyal ankitsamb...@gmail.comwrote: @aditya : can u explain how u got c part as the answer for question 2 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Aditi Garg Undergraduate Student Electronics Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Doubts
@aditi did they mention any thing about miss penalty also in the question ?? On Tue, Aug 9, 2011 at 11:48 AM, aditi garg aditi.garg.6...@gmail.comwrote: @aditya and dipankar: the ans given ws 500ns that is why i posted dis ques...i ws getting the same ans... On Tue, Aug 9, 2011 at 9:45 AM, ankit sambyal ankitsamb...@gmail.comwrote: @aditya : can u explain how u got c part as the answer for question 2 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Aditi Garg Undergraduate Student Electronics Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Doubts
@Rohit:No...i directly copy pasted the ques...nothing else mentioned...and what if thr ws sm miss penalty?what wud be the change in soution? On Tue, Aug 9, 2011 at 1:37 PM, Rohit Srivastava access2ro...@gmail.comwrote: @aditi did they mention any thing about miss penalty also in the question ?? On Tue, Aug 9, 2011 at 11:48 AM, aditi garg aditi.garg.6...@gmail.comwrote: @aditya and dipankar: the ans given ws 500ns that is why i posted dis ques...i ws getting the same ans... On Tue, Aug 9, 2011 at 9:45 AM, ankit sambyal ankitsamb...@gmail.comwrote: @aditya : can u explain how u got c part as the answer for question 2 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Aditi Garg Undergraduate Student Electronics Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Aditi Garg Undergraduate Student Electronics Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Doubts
yup !!! it will increase the avg access time On Tue, Aug 9, 2011 at 1:39 PM, aditi garg aditi.garg.6...@gmail.comwrote: @Rohit:No...i directly copy pasted the ques...nothing else mentioned...and what if thr ws sm miss penalty?what wud be the change in soution? On Tue, Aug 9, 2011 at 1:37 PM, Rohit Srivastava access2ro...@gmail.comwrote: @aditi did they mention any thing about miss penalty also in the question ?? On Tue, Aug 9, 2011 at 11:48 AM, aditi gayrg aditi.garg.6...@gmail.comwrote: @aditya and dipankar: the ans given ws 500ns that is why i posted dis ques...i ws getting the same ans... On Tue, Aug 9, 2011 at 9:45 AM, ankit sambyal ankitsamb...@gmail.comwrote: @aditya : can u explain how u got c part as the answer for question 2 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Aditi Garg Undergraduate Student Electronics Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Aditi Garg Undergraduate Student Electronics Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Doubts
4.94 ns c c b On Tue, Aug 9, 2011 at 1:32 AM, aditi garg aditi.garg.6...@gmail.comwrote: Q1.in a memory hierarchy, M1,M2 M1 access time is 2 ns ,M2 accesstime is 100 ns . the hit ratio for M1 is .97, then what's the avg access time? Q2.two heaps of sizes m,n are given, then the time needed to merge them a)m b)n c)m+n d) none Q3.context switching is useful in a) spooling b) polling c)interrupt handling d) interrupt servicing Q4Reentrant os required a)multitasking b)multiuser c)both d)none -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Doubts
can u explain ques 3 and 4? Fr ques 3 why not interrupt servicing? and in 4 why not both? On Tue, Aug 9, 2011 at 1:42 AM, Aditya Virmani virmanisadi...@gmail.comwrote: 4.94 ns c c b On Tue, Aug 9, 2011 at 1:32 AM, aditi garg aditi.garg.6...@gmail.comwrote: Q1.in a memory hierarchy, M1,M2 M1 access time is 2 ns ,M2 accesstime is 100 ns . the hit ratio for M1 is .97, then what's the avg access time? Q2.two heaps of sizes m,n are given, then the time needed to merge them a)m b)n c)m+n d) none Q3.context switching is useful in a) spooling b) polling c)interrupt handling d) interrupt servicing Q4Reentrant os required a)multitasking b)multiuser c)both d)none -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Aditi Garg Undergraduate Student Electronics Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Doubts
For ques 3, remember that context switch is useful in 3 situations : 1. Multitasking (when CPU is to be switched among processes(usually preemptive)) 2. Interrupt Handling (different from interrupt servicing) - In this, CPU requests for a service (eg read from a disk) but doesnt wait for it to complete. On the other hand, it continues to perform sm othr task after sendin the req. With the help of interrupt handlers, later the CPU is interrupted when the task is over. Thus it req context switch 3. Switch from user and kernel modes (though this varies with OS) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/Eu2sQW7VkXQJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Doubts
In hierarchy M1-M2 0.97 Hit = 2x0.97 = 1.94 ns M2 is not accessed in case of hit 0.03 Miss = 0.03x100 = 3ns (miss rate x miss penalty) Total = 4.94ns +1 to Aditya so the average access time is = hit + miss = 1.94 + 100.06 On 9 August 2011 08:11, Raman raman.u...@gmail.com wrote: For ques 3, remember that context switch is useful in 3 situations : 1. Multitasking (when CPU is to be switched among processes(usually preemptive)) 2. Interrupt Handling (different from interrupt servicing) - In this, CPU requests for a service (eg read from a disk) but doesnt wait for it to complete. On the other hand, it continues to perform sm othr task after sendin the req. With the help of interrupt handlers, later the CPU is interrupted when the task is over. Thus it req context switch 3. Switch from user and kernel modes (though this varies with OS) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/Eu2sQW7VkXQJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Doubts
Sorry for the last line.. Made some error before. On 9 August 2011 08:51, Dipankar Patro dip10c...@gmail.com wrote: In hierarchy M1-M2 0.97 Hit = 2x0.97 = 1.94 ns M2 is not accessed in case of hit 0.03 Miss = 0.03x100 = 3ns (miss rate x miss penalty) Total = 4.94ns +1 to Aditya so the average access time is = hit + miss = 1.94 + 100.06 On 9 August 2011 08:11, Raman raman.u...@gmail.com wrote: For ques 3, remember that context switch is useful in 3 situations : 1. Multitasking (when CPU is to be switched among processes(usually preemptive)) 2. Interrupt Handling (different from interrupt servicing) - In this, CPU requests for a service (eg read from a disk) but doesnt wait for it to complete. On the other hand, it continues to perform sm othr task after sendin the req. With the help of interrupt handlers, later the CPU is interrupted when the task is over. Thus it req context switch 3. Switch from user and kernel modes (though this varies with OS) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/Eu2sQW7VkXQJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Doubts
@aditya : can u explain how u got c part as the answer for question 2 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.