using System;
using System.Threading;
using System.Security.AccessControl;
internal class Example
{
internal static void Main()
{
const string mutexName = "MutexExample4";
Mutex m = null;
bool doesNotExist = false;
bool unauthorized = false;
// The value of this variable is set by the mutex
// constructor. It is true if the named system mutex was
// created, and false if the named mutex already existed.
//
bool mutexWasCreated = false;
// Attempt to open the named mutex.
try
{
// Open the mutex with (MutexRights.Synchronize |
// MutexRights.Modify), to enter and release the
// named mutex.
//
m = Mutex.OpenExisting(mutexName);
}
catch(WaitHandleCannotBeOpenedException)
{
Console.WriteLine("Mutex does not exist.");
doesNotExist = true;
}
catch(UnauthorizedAccessException ex)
{
Console.WriteLine("Unauthorized access: {0}", ex.Message);
unauthorized = true;
}
// There are three cases: (1) The mutex does not exist.
// (2) The mutex exists, but the current user doesn't
// have access. (3) The mutex exists and the user has
// access.
//
if (doesNotExist)
{
// The mutex does not exist, so create it.
// Create an access control list (ACL) that denies the
// current user the right to enter or release the
// mutex, but allows the right to read and change
// security information for the mutex.
//
string user = Environment.UserDomainName + "\\"
+ Environment.UserName;
MutexSecurity mSec = new MutexSecurity();
MutexAccessRule rule = new MutexAccessRule(user,
MutexRights.Synchronize | MutexRights.Modify,
AccessControlType.Deny);
mSec.AddAccessRule(rule);
rule = new MutexAccessRule(user,
MutexRights.ReadPermissions | MutexRights.ChangePermissions,
AccessControlType.Allow);
mSec.AddAccessRule(rule);
// Create a Mutex object that represents the system
// mutex named by the constant 'mutexName', with
// initial ownership for this thread, and with the
// specified security access. The Boolean value that
// indicates creation of the underlying system object
// is placed in mutexWasCreated.
//
m = new Mutex(true, mutexName, out mutexWasCreated, mSec);
// If the named system mutex was created, it can be
// used by the current instance of this program, even
// though the current user is denied access. The current
// program owns the mutex. Otherwise, exit the program.
//
if (mutexWasCreated)
{
Console.WriteLine("Created the mutex.");
}
else
{
Console.WriteLine("Unable to create the mutex.");
return;
}
}
else if (unauthorized)
{
// Open the mutex to read and change the access control
// security. The access control security defined above
// allows the current user to do this.
//
try
{
m = Mutex.OpenExisting(mutexName,
MutexRights.ReadPermissions | MutexRights.ChangePermissions);
// Get the current ACL. This requires
// MutexRights.ReadPermissions.
MutexSecurity mSec = m.GetAccessControl();
string user = Environment.UserDomainName + "\\"
+ Environment.UserName;
// First, the rule that denied the current user
// the right to enter and release the mutex must
// be removed.
MutexAccessRule rule = new MutexAccessRule(user,
MutexRights.Synchronize | MutexRights.Modify,
AccessControlType.Deny);
mSec.RemoveAccessRule(rule);
// Now grant the user the correct rights.
//
rule = new MutexAccessRule(user,
MutexRights.Synchronize | MutexRights.Modify,
AccessControlType.Allow);
mSec.AddAccessRule(rule);
// Update the ACL. This requires
// MutexRights.ChangePermissions.
m.SetAccessControl(mSec);
Console.WriteLine("Updated mutex security.");
// Open the mutex with (MutexRights.Synchronize
// | MutexRights.Modify), the rights required to
// enter and release the mutex.
//
m = Mutex.OpenExisting(mutexName);
}
catch(UnauthorizedAccessException ex)
{
Console.WriteLine("Unable to change permissions: {0}",
ex.Message);
return;
}
}
// If this program created the mutex, it already owns
// the mutex.
//
if (!mutexWasCreated)
{
// Enter the mutex, and hold it until the program
// exits.
//
try
{
Console.WriteLine("Wait for the mutex.");
m.WaitOne();
Console.WriteLine("Entered the mutex.");
}
catch(UnauthorizedAccessException ex)
{
Console.WriteLine("Unauthorized access: {0}", ex.Message);
}
}
Console.WriteLine("Press the Enter key to exit.");
Console.ReadLine();
m.ReleaseMutex();
}
}
操作系统中,前台进程和后台进程有什么区别?特征是什么? 后台程序基本上不和用户交互,优先级别稍微低一点 前台的程序和用户交互,需要较高的响应速度,优先级别稍微高一点 直接从后台手工启动一个进程用得比较...
进程 进程定义 ...‘''' 进程: 进程是程序的一次动态执行过程,它对应了从代码加载、 执行到执行完毕的一个完整过程。 进程是系统进行资源分配和调度...在多任务操作系统中,通过运行多个进程来并发地执行多个任务。...
感谢原文作者首先让我转帖一下从校盟搜到的一篇帖子,的确很不错的:一.... 语法 echo [{on|off}] [message] Sample:@echo off / echo hello world 在实际应用中我们会把这条命令和重定向符号(也称为管道
[精彩] 子进程及时知道父进程已经退出的最简单方案?http://www.chinaunix.net 作者:yuonunix 发表于:2003-10-31 10:14:14【发表评论】 【查看原文】 【C/C++讨论区】【关闭】 要父进程知道子...
-n:一般而言,mount挂上后会在/etc/mtab中写入一笔资料,在系统中没有可写入文件系统的情况下,可以用这个选项取消这个动作。 4.应用技巧 在Linux 和Unix系统上,所有文件都是作为一个大型树(以/为根)的一部分...
第一章 Linux系统初步了解 本章内容 1.1 Linux系统简介 1.2 Linux系统的特点和组成 1.3 Linux版本介绍 1.4 Red Hat Linux系统概述 1.1 Linux系统简介 1.1.1 什么是Linux 1.1.2 Linux系统的产生 ...&...
系统各进程详解 下面列出的都是操作系统的进程,而不是程序的进程,记住这些进程并了解他们的工作原理,用途,能让我们对系统进程的理解提升一个...
转载自... The Google File System 中文版 ...我们设计并实现了Google GFS文件系统,一个面向大规模数据密集型应用的、可伸缩的分布式文件系统。GFS虽然运行在廉价的普遍硬件设备
在做空间数据处理(切片、栅格、矢量等)的时候,数据量总是庞大的,有时候又不想开一个专门的程序执行大量、重复的文件操作,windows本身自带的bat命令是个很好的选择(简单,处理速度快)。 1 dir 该命令可以获取...
最近工作需要用到PE特征,就了解了这方面的东西,搜了很多东西,发现这篇帖子很全面,再对照上PE文件格式的图片,这个帖子 我看了一个小时 ,算是对PE有了一定的了解。发现,PE文件好多东西都存在着里面。接下来是正...
1.BusyBox简介 2.BusyBox下载与编译 官方下载地址:https://busybox.net/downloads/ 3.QEMU启动内核加BusyBox
InnoSetup 是一个免费...第一次发表是在 1997 年,Inno Setup 今天在功能设置和稳定性上的竞争力可能已经超过一些商业的安装程序制作软件。 二、Inno Setup 能干什么? 1.支持现在所有正在使用的 Windows 版...
Linux系统信息存放在文件里,文件与普通的公务文件类似。每个文件都有自己的名字、内容、存放地址及其它一些管理信息,如文件的用户、文件的大小等。文件可以是一封信、一个通讯录,或者是程序的源语句、程序的数据...
文件与目录基本操作 目录: ...三、文件查找命令 find 命令 locate 命令 四、文本处理命令 sort 命令 uniq 命令 五、文本内容统计命令(wc) 六、文件比较命令 七、文件的复制...
ChinaUnix.net 首页 | 论坛 | 博客 | Linux | 人才 | 培训 | 精华 | Wiki | 读书 | 资料 | 手册 | 下载 | 搜索 ChinaUnix首页 > 精华文章 > C/C++ > 正文 [精彩] 子进程及时知道父进程已经退出的最简单方案?...
本文是一篇论文,英文原文标题为The Google File System,在Google Labs上公布, 由blademaster.ixiezi.com的博主Alex翻译为中文,Google GFS文件系统。 现在云计算渐成潮流,对大规模数据应用、可伸缩、高容错的...
vsftpd.conf 是vsftpd的配置文件,用来控制vsftpd的各项功能。默认状态下,它的位置是/etc/vsftpd.conf或者在/etc/vsftpd/vsftpd.conf。 然而,你也可以通过修改配置行来指定到其它目录。这一点很有用,因为也许你...
启动文件:catalina.out 目标字符串:Server startup in tail -f一般我们会采取ctrl+C的方式跳出,但是这样会直接跳出此次脚本的执行进程,catalina.out是tomcat的启动日志,启动日志会出现一个Server startup in *...
操作系统中,前台进程和后台进程有什么区别?特征是什么?后台程序基本上不和用户交互,优先级别稍微低一点 前台的程序和用户交互,需要较高的响应速度,优先级别稍微高一点直接从后台手工启动一个进程用得比较少...
Apache服务器的配置信息全部存储在主配置文件/etc/httpd/conf/httpd.conf中,这个文件中的内容非常多,用wc命令统计一共有1009行,其中大部分是以#开头的注释行。 [root@justin ~]# wc -l /etc/http
1. Process Control 进程控制 1.1 Creating new processes: fork() 创建新进程:fork函数 1.1.1 What does fork() do? fork函数干什么? 1.1.2 Whats the difference between fork() and vfork()? fork函数 与 ...
[精彩] 子进程及时知道父进程已经退出的最简单方案? http://www.chinaunix.net 作者:yuonunix
转自:http://jingyan.baidu.com/article/eb9f7b6dae49c1869364e8ee.html mkdir 1.作用 ...mkdir命令的作用是建立名称为dirname的子目录,与MS DOS下的md命令类似,它的使用权限是所有用户。...-m, ...
我们知道,一个磁盘可以划分成多个分区,每个分区必须先用格式化工具(例如某种mkfs命令)格式化成某种格式的文件系统,然后才能存储文件,格式化的过程会在磁盘上写一些管理存储布局的信息。下图是一个磁盘分区格式...
PE文件格式分析 PE的意思是PortableExecutable(可移植的执行体)。它是Win32环境自身所带的执行文件格式。它的一些特性继承自Unix的Coff(commonobjectfileformat)文件格式。“PortableExecutable”(可移植的执行体)...
一、前言(Preface)------------------PE(“portableexecutable”,可移植的可执行文件)文件格式,是微软WindwosNT,Windows95和Win32子集①中的可执行的二进制文件的格式;在WindowsNT中,驱动程序也是这种格式。...
linux常用命令 一、linux文件系统结构 sudo apt-get install tree tree --help #查看帮助 tree -L 1 #显示文件目录 ...root@ubuntu16 /# tree -L 1 ...├── boot #系统启动文件和核心文件都在这个目录 ├──...
最近各大电商平台不断持续放货,京东,天猫,苏宁,网易等,还有新加入的大军,酒仙网,,国美,华润万家和主播等等……给平台带去了巨大流量。 看到很多小伙伴都撸货撸到手发软,发财发到腿抽筋。一瓶几百+,你算算,这能赚多少钱。是不是不想上班的那种,上班一天才两三百,什么时候才能买到房子。 今天带来一个福利。那就是抢购软件,很实用。朋友圈好多都在用这个抢购。内有教程仔细阅读。最后祝每个伙伴都抢到 赚到
酒店管理系统分为前台和后台两个部分,其中后台供管理员管理系统之用,包括客房类型设置模块、客房设置模块以及操作员设置三个子模块,具体的功能模块如下。
客房类型设置模块:该模块用来管理酒店的所有客房类型,包括新增客房类型、编辑已有客房类型、删除客房类型等功能。
客房设置模块:该模块用来管理酒店的所有客房信息,包括新增客房、编辑已有客房、删除客房等功能。
操作员设置模块:该模块用来管理酒店的操作员信息,包括新增操作员、编辑已有操作员信息、删除操作信息等功能。
系统前台供酒店所有工作人员使用,包括入住登记模块、结账模块、预定模块、客户管理模块以及业务统计五个模块。具体的功能模块如下。
入住登记模块:该模块用来登记客户的入住信息,其中入住信息包括登记信息、客人信息以及费用信息三部分。
结账模块:该模块用来处理客户的退房信息,只需要知道客户所住的房间号码,就能进行退房结账。
预定模块:该模块用来处理客户的预定信息,除了可以新增预定信息外,还可以对已有的预定信息进行管理。
客户管理模块:该模块用来管理客户的登记信息,包括新增客户信息、编译已有客户信息、删除客户信息等功能。
业务统计模块:该模块用来统计酒店的客房出租率,并且已图形报表的形式来显示出租率信息。
本系统的开发工具具体如下。
系统开发平台:MyEclipse 6.5。
数据库管理系统软件:MySQL 5.0。
java开发包:JDK 5.0以上。
Web服务器:Tomcat 6.0。
本系统采用MVC架构模式开发,具体技术如下。
AJAX框架:使用ExtJS技术开发
显示层:使用JSP技术开发
数据访问层:使用DAO模式开发
持久层:使用Hibernate框架开发
首页访问地址 :http://localhost:8080/JavaPrj_9/首页配置 页面 修改 打开web.xml
修改 即可