Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX:what is the magic cookie and what ...?(contrator)

 
song bo
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,everybody.
the first question:
Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record

what is the meaning of the magin cookie value?what functions for it?"Identifies this as a data file",why?
the second question:
Locking
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above. You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server. Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.

I have seen many discussions here about the record or database locking and unlocking.should I lock the whole database?if so.why?when should I do this action?I only want to lock the record by recno.thus it's avaiable to handle mutiple connections.
thanks.
 
ulvi ugur
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by song bo:
hi,everybody.
the first question:
Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record

what is the meaning of the magin cookie value?what functions for it?"Identifies this as a data file",why?
the second question:
Locking
Your server must be capable of handling multiple concurrent requests, and as part of this capability, must provide locking functionality as specified in the interface provided above. You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server. Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.

I have seen many discussions here about the record or database locking and unlocking.should I lock the whole database?if so.why?when should I do this action?I only want to lock the record by recno.thus it's avaiable to handle mutiple connections.
thanks.

Hi song,
The magic cookie number is there for you to verify that this is the file you are looking for. When the user assigns a wrong file, you can say "Chosen file is not valid !".
About locking, well I guess there is no need to lock the database, only locking records must be enough with the networked run. With standalone run, I'm not sure if there could/should be a file locking so that only one user can get connected to the db file. May be sb. else would say stg. about that :roll:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic