SlideShare a Scribd company logo
lastTrans = 1;
int start()
{
if (lastTrans < 0) { return -1 }
else
{
lastTrans = -(++lastTrans);
return lastTrans
}
}
Assignment 1, Code
• As background to review the solution
1/11/2012 CSEP 545 1
int read(int diskBlockAddr, int tId, int *memBlock)
{
/* find the cache element e containing the block whose
disk address is diskBlockAddr */
if (there is such a cache element e) {
/* the disk block at diskBlockAddr is in cache */
Cache(e).tId = tId;
memBlock = &Cache(e).newBlock;
/* &Cache(e).newBlock = address of Cache(e).newBlock */
return 0
}
else {
/* pick a cache entry e, where Cache(e).tId = 0.
If there is no such entry, then return -1 */
status = diskRead(diskBlockAddr, &Cache(e).oldBlock);
if(status != 0) {return -1};
Cache(e).newBlock = Cache(e).oldBlock;
memBlock = &Cache(e).newBlock;
Cache(e).diskBlockAddr = diskBlockAddr;
Cache(e).tId = tId;
return 0
}
}1/11/2012 CSEP 545 2
/* A transaction should call
write(&Cache(e).newBlock, tId)
after it updates Cache(e).newBlock. */
int write(int diskBlockAddr, int tId)
{
/* find cache entry e for block diskBlockAddr */
if (there is no such entry) { return 0 }
else
{
Cache(e).tId = tId;
return 1
}
}
1/11/2012 CSEP 545 3
int commit(int tId)
{
for (each cache entry e where Cache(e).tId == tId)
{
status = diskWrite(Cache(e).diskBlockAddr,
&Cache(e).newBlock);
Cache(e).tId = - tId;
if (status == -1) {
Abort(tId);
return -1
}
Cache(e).oldBlock = Cache(e).newBlock
}
for (each cache entry e where Cache(e).tId == -tId){
Cache(e).tId = 0
}
lastTrans = -lastTrans;
return 0
}
1/11/2012 CSEP 545 4
int abort(int tId)
{
for (all cache entries e, where Cache(e).tId == -tId)
{
repeat
{
status = diskWrite(Cache(e).diskBlockAddr,
&Cache(e).oldBlock)
} until (status == 0);
/* Of course, this will not terminate if diskWrite
keeps failing, but ignore that issue */
Cache(e).newBlock = Cache(e).oldBlock
}
for (all cache entries e) {
Cache(e).tId = 0
}
lastTrans = -lastTrans;
return 0
}
1/11/2012 CSEP 545 5

More Related Content

What's hot

Correcting Common .NET Async/Await Mistakes
Correcting Common .NET Async/Await MistakesCorrecting Common .NET Async/Await Mistakes
Correcting Common .NET Async/Await Mistakes
Brandon Minnick, MBA
 
Scalable Socket Server by Aryo
Scalable Socket Server by AryoScalable Socket Server by Aryo
Scalable Socket Server by Aryo
Agate Studio
 
ReactiveMongo - non blocking and asynchronous I/O operations
ReactiveMongo - non blocking and asynchronous I/O operationsReactiveMongo - non blocking and asynchronous I/O operations
ReactiveMongo - non blocking and asynchronous I/O operations
David Pichsenmeister
 
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
병완 임
 
MIDP: Persistant Storage
MIDP: Persistant StorageMIDP: Persistant Storage
MIDP: Persistant Storage
Jussi Pohjolainen
 
Ac2
Ac2Ac2
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Arian Gutierrez
 
Circuit breaker
Circuit breakerCircuit breaker
Circuit breaker
bricemciver
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
Knoldus Inc.
 
Reactive Quarkus – A Java Mutiny! | DevNation Tech Talk
Reactive Quarkus – A Java Mutiny! | DevNation Tech TalkReactive Quarkus – A Java Mutiny! | DevNation Tech Talk
Reactive Quarkus – A Java Mutiny! | DevNation Tech Talk
Red Hat Developers
 
The Ring programming language version 1.5.1 book - Part 65 of 180
The Ring programming language version 1.5.1 book - Part 65 of 180The Ring programming language version 1.5.1 book - Part 65 of 180
The Ring programming language version 1.5.1 book - Part 65 of 180
Mahmoud Samir Fayed
 
Node.js and angular js
Node.js and angular jsNode.js and angular js
Node.js and angular js
HyungKuIm
 
Vcs24
Vcs24Vcs24
The Ring programming language version 1.6 book - Part 71 of 189
The Ring programming language version 1.6 book - Part 71 of 189The Ring programming language version 1.6 book - Part 71 of 189
The Ring programming language version 1.6 book - Part 71 of 189
Mahmoud Samir Fayed
 
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki LinnakangasPG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
pgdayrussia
 
Node.js - As a networking tool
Node.js - As a networking toolNode.js - As a networking tool
Node.js - As a networking tool
Felix Geisendörfer
 

What's hot (16)

Correcting Common .NET Async/Await Mistakes
Correcting Common .NET Async/Await MistakesCorrecting Common .NET Async/Await Mistakes
Correcting Common .NET Async/Await Mistakes
 
Scalable Socket Server by Aryo
Scalable Socket Server by AryoScalable Socket Server by Aryo
Scalable Socket Server by Aryo
 
ReactiveMongo - non blocking and asynchronous I/O operations
ReactiveMongo - non blocking and asynchronous I/O operationsReactiveMongo - non blocking and asynchronous I/O operations
ReactiveMongo - non blocking and asynchronous I/O operations
 
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
BlockchainDay "Ethereum Dapp - Asset Exchange YOSEMITE alpha" Session
 
MIDP: Persistant Storage
MIDP: Persistant StorageMIDP: Persistant Storage
MIDP: Persistant Storage
 
Ac2
Ac2Ac2
Ac2
 
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
 
Circuit breaker
Circuit breakerCircuit breaker
Circuit breaker
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Reactive Quarkus – A Java Mutiny! | DevNation Tech Talk
Reactive Quarkus – A Java Mutiny! | DevNation Tech TalkReactive Quarkus – A Java Mutiny! | DevNation Tech Talk
Reactive Quarkus – A Java Mutiny! | DevNation Tech Talk
 
The Ring programming language version 1.5.1 book - Part 65 of 180
The Ring programming language version 1.5.1 book - Part 65 of 180The Ring programming language version 1.5.1 book - Part 65 of 180
The Ring programming language version 1.5.1 book - Part 65 of 180
 
Node.js and angular js
Node.js and angular jsNode.js and angular js
Node.js and angular js
 
Vcs24
Vcs24Vcs24
Vcs24
 
The Ring programming language version 1.6 book - Part 71 of 189
The Ring programming language version 1.6 book - Part 71 of 189The Ring programming language version 1.6 book - Part 71 of 189
The Ring programming language version 1.6 book - Part 71 of 189
 
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki LinnakangasPG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
 
Node.js - As a networking tool
Node.js - As a networking toolNode.js - As a networking tool
Node.js - As a networking tool
 

Viewers also liked

05 tp mon_orbs
05 tp mon_orbs05 tp mon_orbs
05 tp mon_orbs
ashish61_scs
 
10a log
10a log10a log
10a log
ashish61_scs
 
Transactions
TransactionsTransactions
Transactions
ashish61_scs
 
Dynamic Power of QFT - Copy
Dynamic Power of QFT - CopyDynamic Power of QFT - Copy
Dynamic Power of QFT - Copy
Jacques Benoit
 
21 domino mohan-1
21 domino mohan-121 domino mohan-1
21 domino mohan-1
ashish61_scs
 
03 fault model
03 fault model03 fault model
03 fault model
ashish61_scs
 
MarkH-CV 2015
MarkH-CV 2015MarkH-CV 2015
MarkH-CV 2015
Mark Houstoun
 
4G MOBILE COMMUNICATION SYSTEM
4G MOBILE COMMUNICATION SYSTEM4G MOBILE COMMUNICATION SYSTEM
4G MOBILE COMMUNICATION SYSTEM
lalit kumar
 
Solution5.2012
Solution5.2012Solution5.2012
Solution5.2012
ashish61_scs
 
15 bufferand records
15 bufferand records15 bufferand records
15 bufferand records
ashish61_scs
 
UPDATED INTERVIEW GUIDE
UPDATED INTERVIEW GUIDEUPDATED INTERVIEW GUIDE
UPDATED INTERVIEW GUIDE
Khang Vang
 
Emerging Trends and Tech
Emerging Trends and TechEmerging Trends and Tech
Emerging Trends and Tech
Quick Marketing
 

Viewers also liked (13)

05 tp mon_orbs
05 tp mon_orbs05 tp mon_orbs
05 tp mon_orbs
 
10a log
10a log10a log
10a log
 
Transactions
TransactionsTransactions
Transactions
 
Dynamic Power of QFT - Copy
Dynamic Power of QFT - CopyDynamic Power of QFT - Copy
Dynamic Power of QFT - Copy
 
21 domino mohan-1
21 domino mohan-121 domino mohan-1
21 domino mohan-1
 
03 fault model
03 fault model03 fault model
03 fault model
 
MarkH-CV 2015
MarkH-CV 2015MarkH-CV 2015
MarkH-CV 2015
 
pics
picspics
pics
 
4G MOBILE COMMUNICATION SYSTEM
4G MOBILE COMMUNICATION SYSTEM4G MOBILE COMMUNICATION SYSTEM
4G MOBILE COMMUNICATION SYSTEM
 
Solution5.2012
Solution5.2012Solution5.2012
Solution5.2012
 
15 bufferand records
15 bufferand records15 bufferand records
15 bufferand records
 
UPDATED INTERVIEW GUIDE
UPDATED INTERVIEW GUIDEUPDATED INTERVIEW GUIDE
UPDATED INTERVIEW GUIDE
 
Emerging Trends and Tech
Emerging Trends and TechEmerging Trends and Tech
Emerging Trends and Tech
 

More from ashish61_scs

7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwo
ashish61_scs
 
22 levine
22 levine22 levine
22 levine
ashish61_scs
 
20 access paths
20 access paths20 access paths
20 access paths
ashish61_scs
 
19 structured files
19 structured files19 structured files
19 structured files
ashish61_scs
 
18 philbe replication stanford99
18 philbe replication stanford9918 philbe replication stanford99
18 philbe replication stanford99
ashish61_scs
 
17 wics99 harkey
17 wics99 harkey17 wics99 harkey
17 wics99 harkey
ashish61_scs
 
16 greg hope_com_wics
16 greg hope_com_wics16 greg hope_com_wics
16 greg hope_com_wics
ashish61_scs
 
14 turing wics
14 turing wics14 turing wics
14 turing wics
ashish61_scs
 
14 scaleabilty wics
14 scaleabilty wics14 scaleabilty wics
14 scaleabilty wics
ashish61_scs
 
13 tm adv
13 tm adv13 tm adv
13 tm adv
ashish61_scs
 
11 tm
11 tm11 tm
10b rm
10b rm10b rm
10b rm
ashish61_scs
 
09 workflow
09 workflow09 workflow
09 workflow
ashish61_scs
 
08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick
ashish61_scs
 
06 07 lock
06 07 lock06 07 lock
06 07 lock
ashish61_scs
 
04 transaction models
04 transaction models04 transaction models
04 transaction models
ashish61_scs
 
02 fault tolerance
02 fault tolerance02 fault tolerance
02 fault tolerance
ashish61_scs
 
01 whirlwind tour
01 whirlwind tour01 whirlwind tour
01 whirlwind tour
ashish61_scs
 
Solution6.2012
Solution6.2012Solution6.2012
Solution6.2012
ashish61_scs
 
Solution7.2012
Solution7.2012Solution7.2012
Solution7.2012
ashish61_scs
 

More from ashish61_scs (20)

7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwo
 
22 levine
22 levine22 levine
22 levine
 
20 access paths
20 access paths20 access paths
20 access paths
 
19 structured files
19 structured files19 structured files
19 structured files
 
18 philbe replication stanford99
18 philbe replication stanford9918 philbe replication stanford99
18 philbe replication stanford99
 
17 wics99 harkey
17 wics99 harkey17 wics99 harkey
17 wics99 harkey
 
16 greg hope_com_wics
16 greg hope_com_wics16 greg hope_com_wics
16 greg hope_com_wics
 
14 turing wics
14 turing wics14 turing wics
14 turing wics
 
14 scaleabilty wics
14 scaleabilty wics14 scaleabilty wics
14 scaleabilty wics
 
13 tm adv
13 tm adv13 tm adv
13 tm adv
 
11 tm
11 tm11 tm
11 tm
 
10b rm
10b rm10b rm
10b rm
 
09 workflow
09 workflow09 workflow
09 workflow
 
08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick
 
06 07 lock
06 07 lock06 07 lock
06 07 lock
 
04 transaction models
04 transaction models04 transaction models
04 transaction models
 
02 fault tolerance
02 fault tolerance02 fault tolerance
02 fault tolerance
 
01 whirlwind tour
01 whirlwind tour01 whirlwind tour
01 whirlwind tour
 
Solution6.2012
Solution6.2012Solution6.2012
Solution6.2012
 
Solution7.2012
Solution7.2012Solution7.2012
Solution7.2012
 

Recently uploaded

Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
Celine George
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
nitinpv4ai
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
JomonJoseph58
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 

Recently uploaded (20)

Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 

Assignment1.2012

  • 1. lastTrans = 1; int start() { if (lastTrans < 0) { return -1 } else { lastTrans = -(++lastTrans); return lastTrans } } Assignment 1, Code • As background to review the solution 1/11/2012 CSEP 545 1
  • 2. int read(int diskBlockAddr, int tId, int *memBlock) { /* find the cache element e containing the block whose disk address is diskBlockAddr */ if (there is such a cache element e) { /* the disk block at diskBlockAddr is in cache */ Cache(e).tId = tId; memBlock = &Cache(e).newBlock; /* &Cache(e).newBlock = address of Cache(e).newBlock */ return 0 } else { /* pick a cache entry e, where Cache(e).tId = 0. If there is no such entry, then return -1 */ status = diskRead(diskBlockAddr, &Cache(e).oldBlock); if(status != 0) {return -1}; Cache(e).newBlock = Cache(e).oldBlock; memBlock = &Cache(e).newBlock; Cache(e).diskBlockAddr = diskBlockAddr; Cache(e).tId = tId; return 0 } }1/11/2012 CSEP 545 2
  • 3. /* A transaction should call write(&Cache(e).newBlock, tId) after it updates Cache(e).newBlock. */ int write(int diskBlockAddr, int tId) { /* find cache entry e for block diskBlockAddr */ if (there is no such entry) { return 0 } else { Cache(e).tId = tId; return 1 } } 1/11/2012 CSEP 545 3
  • 4. int commit(int tId) { for (each cache entry e where Cache(e).tId == tId) { status = diskWrite(Cache(e).diskBlockAddr, &Cache(e).newBlock); Cache(e).tId = - tId; if (status == -1) { Abort(tId); return -1 } Cache(e).oldBlock = Cache(e).newBlock } for (each cache entry e where Cache(e).tId == -tId){ Cache(e).tId = 0 } lastTrans = -lastTrans; return 0 } 1/11/2012 CSEP 545 4
  • 5. int abort(int tId) { for (all cache entries e, where Cache(e).tId == -tId) { repeat { status = diskWrite(Cache(e).diskBlockAddr, &Cache(e).oldBlock) } until (status == 0); /* Of course, this will not terminate if diskWrite keeps failing, but ignore that issue */ Cache(e).newBlock = Cache(e).oldBlock } for (all cache entries e) { Cache(e).tId = 0 } lastTrans = -lastTrans; return 0 } 1/11/2012 CSEP 545 5