Python Forum
time taken for storage to get full
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
time taken for storage to get full
#1
I have been given a homework to find out time it will take to fill the storage.

Let's assume that n number of processes are running on the computer. They run forever, never die, and no new processes get spawned. Each process takes memory at a constant,
individual rate - process p_i (with 0 <= i < n) consumes 1 byte after
every d(p_i) seconds. The total amount of available disk space is denoted by X.

calculate the time to fill up available storage in seconds ?

I am little confused by p_i (with 0 <= i < n)
if processes run forever and never die an no new process get spawned then if rate is constant
it should be 1 byte / second. but why in question is d(p_i) seconds!

if 1 byte/ second is constant rate then is it correct to say time taken

time_taken = available_storage/(write_speed * number_of_processes)
Reply
#2
The rate is constant for each process, but is not constant across processes. So the rate for p_0 is not the same as the rate for p_1, but neither rate changes over time.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
Hi if different speed in that case is this logic correct ?

number_of_processes = 3
available_storage = 6 # in bytes
write_speed_x = 1 #(byte/ x second)
write_speed_y = 3
write_speed_z = 2
timeTaken = 0

pr_i = [write_speed_x, write_speed_y, write_speed_z]

for i in pr_i:
timeTaken += available_storage/i


print timeTaken

Reply
#4
Use python tags for multi-line code. The icode tag is for inline code.

You are calculating the time each process would take by itself to fill the data, and then adding them together. That's going to be far longer than it will take all of the processes working together to consume all of the data.

There's a brute force way to do this by looping through seconds, checking each process each second to see if it consume a byte, until all the memory is consumed.

There's a quicker method using the least common multiple of the process times. Then you will know that all of the processes consume x bytes every y seconds. You will still have a little time left over after that, but you can use the brute force method to get the remainder of the time.

There's probably a better solution than than, but it's too early in the morning to get my algorithms book off the shelf.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020