Say one program reads an F.txt file, and another program writes that file at the same time.
(When I think about how to implement this functionality if I were a system programmer), I understand that there can be ambiguity in:
what will the first program see?
where does the second program write new bytes? (ie write "in place", instead of writing to a new file, and then replace the old file with a new one)
how many programs can be written to the same file at the same time?
.. and maybe something is not so obvious.
So my questions are:
What are the main strategies for reading / writing files?
which of them are supported in OS (Windows, Linux, Mac OS, etc.)?
Can it depend on a particular programming language? (I can assume that Java might try to provide some unified behavior for all supported OSs)
Single-byte reading has a long journey to go from a magnetic plate / flash cell to your local Java variable. This is a single byte path:
fopen()
, , , .
, Java :
FileInputStream fis = new FileInputStream("/home/vz0/F.txt"); // This byte comes from the user space buffer. int oneByte = fis.read();
4 . , " ", , , .
, , :
"" , . , :
, . Java Channel IO , .
RAM , sync. , , -, , .
sync
, - , , .
(Windows NT , Linux, MacOS, * BSD) .
http://ezinearticles.com/?How-an-Operating-Systems-File-System-Works&id=980216
, . , SO - . . , (, MySQL MyISAM engine )
JVM , fsync(), SO, . JVM , , .
Source: https://habr.com/ru/post/1789379/More articles:How can I get a list of all directory names and / or all files in a specific directory in MATLAB? - filesystemsASP.NET MVC3 Razor - What does @ * do? - asp.net-mvc-3When I upload a new view to Cocoa Touch, it shifts everything by about 20 pixels - iosIs there any way to find which accounts xp_cmdshell can run? - sqlSurvey Template for Silverlight 4 WCF Ria Services - silverlight-4.0https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1789380/distributing-list-items-to-variables-in-python&usg=ALkJrhiHKpnsKpejA_UmZmWhSR9LbyqYYQConditional macroC # define for a function that calls: "function" overridden warning - gccRandom long I / O delays during periodic data recording - javaConditional value for #define - macrosHow do you guarantee that your MVC routes do not conflict with each other? What tracking system do you use? - model-view-controllerAll Articles