struct pipe { bmutext_t b; condvar_t nonfull, nonempty; //want to wait for if the pipe is not full so that people can write to it or if the pipe is nonempty so we know that we can read from it; non full for writers and nonempty for readers. size_t r, w; //Store the read and write bytes char buf[N]; }; void writec(struct pipe* p, char c) { acquire(&p->b) //Acquire the spin lock and if we can't get it then we block while(p->w - p-> r == N) //While the pipe is full {
wait(&p->nonfull, &p->b); //Condition variable function } p->buf[p->w++ %N]=c; release(&p->b); notify(&p->nonempty); //This does not guarantee to the other threads that the condition is true. All we are saying is that the condition might be true, so the other threads should wake up to check it. }
//Copy primitive that allows us to copy everything at once while(copy(0,1,40%) > 0) continue;
Seagate Barracuda ES2 1TB | |
---|---|
16 MiB | cache |
7200 rpm | drive |
8.333 ms | rotation time |
4,166 ms | average latency - amount of time it will take for the data to come under the read head will be half of the rational time |
8.5 ms | average read seek - if you choose two track numbers at random and measure how long it takes to accelerate and decelerate the heads from one track to another. |
9.5 ms | average write seek - Takes longer because you are writing data as the head moves and write has to be a lot more accurate because if you are a little bit off you might leak and write data into the wrong track |
0.8 ms/1.0ms | Track-to-track seek - If you are seeking in one track and you want to go to another track |
1.29 Gb/s | Maximum internal transfer rate - rate at which data comes off the disk and onto the cache. If the data is closer to the edges then it is faster to transfer the data. |
3 Gb/s | External transfer rate - Rate at which you transfer data from the disk controller cache to the bus |
512, 520, 524, 528 bytes/sector | We can configure the disk drive to have a different number of bytes per sector. Standard is 512 bytes/sector |
12.5 W | Will use 12.5 watts when it is running |
9 W | Idle- Will use 9 watts if it is not doing anything and just staying idle |
.73% AFR | annualized failure rate (24*7)- If you use the machine for a year straight then there is an .73% chance that it will crash and you will have to replace it. |
10^-15 nonrecoverable read failure rate | Probability that the disk will lose the sector |
Corsair Force GT (Flash Memory) | |
---|---|
60 GB | Capacity |
2.0 W | Capacity |
1,000,000 hours | Mean time before failure |
1.74 GB/s | read |
1.7 Mb/s | write |
0s | latency |
for(;;) { char c; if(read(0,&c,1) !=1) //Suppose this does all the steps above dealing with hard disks - Total read time will be long because the read time will be = 8.5(average read seek) + 4.16 ms(average latency) + (.0005 MB/100Mb/s) (max sustained transfer rate) break; process(c); }
for(;;) { char c; if(read(0,&c,1024)!=1) break; process(c);//If the process takes a long time then batching won't have that much of an effect, but if the process is short then the run time will be increased by around 1000 times }