Added lock when writing to a file package.

Signed-off-by: Konctantin <gawrilyako@gmail.com>
Move declaration to szimat.h file

Signed-off-by: Konctantin <gawrilyako@gmail.com>