Last active
May 6, 2020 19:39
-
-
Save deeev-sb/38b26f6355a795eb337f8c18ac0971f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open the master account file; | |
while (true) { | |
get the operation type and information on the account | |
switch (operation) { // user가 원하는 작업 세분화 | |
case create: // 새로운 record 생성 | |
get a writer’s lock on the record; // record 정보 update이므로 writer's lock 설정 | |
get id and name of the user; // user로부터 id와 name을 입력받음 (새로운 account 생성이므로 balance는 0) | |
reset the account information; // account 정보 update | |
release the writer’s lock; // writer's lock 해제 | |
case inquiry: // read balance | |
get a reader’s’ lock on that record; // account 정보를 읽는 작업을 수행하므로 reader's lock 설정 | |
(if a write lock exists, blocked) | |
display the account information; // account 정보 출력 | |
release the reader’s lock; // reader's lock 해제 | |
case deposit (or withdraw): // update balance | |
get a writer’s lock on that record; // balance 값을 변경하므로 writer's lock 설정 | |
(if a writer’s or a reader’s lock exists, blocked) | |
display the account information; // 변경된 account 정보 출력 | |
release the writer’s lock; // writer's lock 해제 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment